Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: chrome/browser/extensions/api/preference/preference_apitest.cc

Issue 334083002: Add a test helper class for ExtensionRegistry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ben's comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_test_message_listener.h" 10 #include "chrome/browser/extensions/extension_test_message_listener.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "components/translate/core/common/translate_pref_names.h" 16 #include "components/translate/core/common/translate_pref_names.h"
17 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/extension_test_registry_observer.h"
18 20
19 namespace { 21 namespace {
20 22
21 void ReleaseBrowserProcessModule() { 23 void ReleaseBrowserProcessModule() {
22 g_browser_process->ReleaseModule(); 24 g_browser_process->ReleaseModule();
23 } 25 }
24 26
25 } // namespace 27 } // namespace
26 28
27 class ExtensionPreferenceApiTest : public ExtensionApiTest { 29 class ExtensionPreferenceApiTest : public ExtensionApiTest {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 112
111 EXPECT_TRUE(RunExtensionSubtest(kExtensionPath, "test.html")) << message_; 113 EXPECT_TRUE(RunExtensionSubtest(kExtensionPath, "test.html")) << message_;
112 CheckPreferencesSet(); 114 CheckPreferencesSet();
113 115
114 // The settings should not be reset when the extension is reloaded. 116 // The settings should not be reset when the extension is reloaded.
115 ReloadExtension(last_loaded_extension_id()); 117 ReloadExtension(last_loaded_extension_id());
116 CheckPreferencesSet(); 118 CheckPreferencesSet();
117 119
118 // Uninstalling and installing the extension (without running the test that 120 // Uninstalling and installing the extension (without running the test that
119 // calls the extension API) should clear the settings. 121 // calls the extension API) should clear the settings.
120 content::WindowedNotificationObserver observer( 122 extensions::ExtensionTestRegistryObserver observer(
121 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, 123 extensions::ExtensionRegistry::Get(profile_));
122 content::NotificationService::AllSources());
123 UninstallExtension(last_loaded_extension_id()); 124 UninstallExtension(last_loaded_extension_id());
124 observer.Wait(); 125 observer.WaitForAnyExtensionUninstalled();
125 CheckPreferencesCleared(); 126 CheckPreferencesCleared();
126 127
127 LoadExtension(test_data_dir_.AppendASCII(kExtensionPath)); 128 LoadExtension(test_data_dir_.AppendASCII(kExtensionPath));
128 CheckPreferencesCleared(); 129 CheckPreferencesCleared();
129 } 130 }
130 131
131 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, PersistentIncognito) { 132 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, PersistentIncognito) {
132 PrefService* prefs = profile_->GetPrefs(); 133 PrefService* prefs = profile_->GetPrefs();
133 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false); 134 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false);
134 135
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 311
311 // Test 6 - clearDefault 312 // Test 6 - clearDefault
312 EXPECT_TRUE(listener10.WaitUntilSatisfied()); // Regular ready 313 EXPECT_TRUE(listener10.WaitUntilSatisfied()); // Regular ready
313 EXPECT_TRUE(listener_incognito10.WaitUntilSatisfied()); // Incognito ready 314 EXPECT_TRUE(listener_incognito10.WaitUntilSatisfied()); // Incognito ready
314 listener10.Reply("ok"); 315 listener10.Reply("ok");
315 listener_incognito10.Reply("ok"); 316 listener_incognito10.Reply("ok");
316 317
317 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 318 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
318 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); 319 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message();
319 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698