| OLD | NEW |
| 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" | 18 #include "extensions/browser/extension_registry.h" |
| 19 #include "extensions/browser/test_extension_registry_observer.h" | 19 #include "extensions/browser/test_extension_registry_observer.h" |
| 20 #include "extensions/test/result_catcher.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 void ReleaseBrowserProcessModule() { | 24 void ReleaseBrowserProcessModule() { |
| 24 g_browser_process->ReleaseModule(); | 25 g_browser_process->ReleaseModule(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| 29 class ExtensionPreferenceApiTest : public ExtensionApiTest { | 30 class ExtensionPreferenceApiTest : public ExtensionApiTest { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 EXPECT_FALSE(pref->IsExtensionControlled()); | 200 EXPECT_FALSE(pref->IsExtensionControlled()); |
| 200 EXPECT_EQ(true, prefs->GetBoolean(prefs::kBlockThirdPartyCookies)); | 201 EXPECT_EQ(true, prefs->GetBoolean(prefs::kBlockThirdPartyCookies)); |
| 201 } | 202 } |
| 202 | 203 |
| 203 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, OnChange) { | 204 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, OnChange) { |
| 204 EXPECT_TRUE(RunExtensionTestIncognito("preference/onchange")) << | 205 EXPECT_TRUE(RunExtensionTestIncognito("preference/onchange")) << |
| 205 message_; | 206 message_; |
| 206 } | 207 } |
| 207 | 208 |
| 208 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, OnChangeSplit) { | 209 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, OnChangeSplit) { |
| 209 ResultCatcher catcher; | 210 extensions::ResultCatcher catcher; |
| 210 catcher.RestrictToProfile(profile_); | 211 catcher.RestrictToBrowserContext(profile_); |
| 211 ResultCatcher catcher_incognito; | 212 extensions::ResultCatcher catcher_incognito; |
| 212 catcher_incognito.RestrictToProfile(profile_->GetOffTheRecordProfile()); | 213 catcher_incognito.RestrictToBrowserContext( |
| 214 profile_->GetOffTheRecordProfile()); |
| 213 | 215 |
| 214 // Open an incognito window. | 216 // Open an incognito window. |
| 215 ui_test_utils::OpenURLOffTheRecord(profile_, GURL("chrome://newtab/")); | 217 ui_test_utils::OpenURLOffTheRecord(profile_, GURL("chrome://newtab/")); |
| 216 | 218 |
| 217 // changeDefault listeners. | 219 // changeDefault listeners. |
| 218 ExtensionTestMessageListener listener1("changeDefault regular ready", true); | 220 ExtensionTestMessageListener listener1("changeDefault regular ready", true); |
| 219 ExtensionTestMessageListener listener_incognito1( | 221 ExtensionTestMessageListener listener_incognito1( |
| 220 "changeDefault incognito ready", true); | 222 "changeDefault incognito ready", true); |
| 221 | 223 |
| 222 // changeIncognitoOnly listeners. | 224 // changeIncognitoOnly listeners. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 319 |
| 318 // Test 6 - clearDefault | 320 // Test 6 - clearDefault |
| 319 EXPECT_TRUE(listener10.WaitUntilSatisfied()); // Regular ready | 321 EXPECT_TRUE(listener10.WaitUntilSatisfied()); // Regular ready |
| 320 EXPECT_TRUE(listener_incognito10.WaitUntilSatisfied()); // Incognito ready | 322 EXPECT_TRUE(listener_incognito10.WaitUntilSatisfied()); // Incognito ready |
| 321 listener10.Reply("ok"); | 323 listener10.Reply("ok"); |
| 322 listener_incognito10.Reply("ok"); | 324 listener_incognito10.Reply("ok"); |
| 323 | 325 |
| 324 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 326 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 325 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 327 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 326 } | 328 } |
| OLD | NEW |