| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 10 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(SyncChangeProcessorDelegate); | 102 DISALLOW_COPY_AND_ASSIGN(SyncChangeProcessorDelegate); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 class MockSchemaRegistryObserver : public policy::SchemaRegistry::Observer { | 105 class MockSchemaRegistryObserver : public policy::SchemaRegistry::Observer { |
| 106 public: | 106 public: |
| 107 MockSchemaRegistryObserver() {} | 107 MockSchemaRegistryObserver() {} |
| 108 virtual ~MockSchemaRegistryObserver() {} | 108 virtual ~MockSchemaRegistryObserver() {} |
| 109 | 109 |
| 110 MOCK_METHOD1(OnSchemaRegistryUpdated, void(bool)); | 110 MOCK_METHOD1(OnSchemaRegistryUpdated, void(bool)); |
| 111 MOCK_METHOD0(OnSchemaRegistryReady, void()); |
| 111 }; | 112 }; |
| 112 | 113 |
| 113 } // namespace | 114 } // namespace |
| 114 | 115 |
| 115 class ExtensionSettingsApiTest : public ExtensionApiTest { | 116 class ExtensionSettingsApiTest : public ExtensionApiTest { |
| 116 protected: | 117 protected: |
| 117 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 118 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 118 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 119 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 119 | 120 |
| 120 #if defined(ENABLE_CONFIGURATION_POLICY) | 121 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 121 EXPECT_CALL(policy_provider_, IsInitializationComplete(_)) | 122 EXPECT_CALL(policy_provider_, IsInitializationComplete(_)) |
| 122 .WillRepeatedly(Return(true)); | 123 .WillRepeatedly(Return(true)); |
| 124 policy_provider_.SetAutoRefresh(); |
| 123 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( | 125 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( |
| 124 &policy_provider_); | 126 &policy_provider_); |
| 125 #endif | 127 #endif |
| 126 } | 128 } |
| 127 | 129 |
| 128 void ReplyWhenSatisfied( | 130 void ReplyWhenSatisfied( |
| 129 Namespace settings_namespace, | 131 Namespace settings_namespace, |
| 130 const std::string& normal_action, | 132 const std::string& normal_action, |
| 131 const std::string& incognito_action) { | 133 const std::string& incognito_action) { |
| 132 MaybeLoadAndReplyWhenSatisfied( | 134 MaybeLoadAndReplyWhenSatisfied( |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 // Now change the policies and wait until the extension is done. | 580 // Now change the policies and wait until the extension is done. |
| 579 policy = extensions::DictionaryBuilder() | 581 policy = extensions::DictionaryBuilder() |
| 580 .Set("constant-policy", "aaa") | 582 .Set("constant-policy", "aaa") |
| 581 .Set("changes-policy", "ddd") | 583 .Set("changes-policy", "ddd") |
| 582 .Set("new-policy", "eee") | 584 .Set("new-policy", "eee") |
| 583 .Build(); | 585 .Build(); |
| 584 SetPolicies(*policy); | 586 SetPolicies(*policy); |
| 585 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 587 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 586 } | 588 } |
| 587 | 589 |
| 588 #if defined(OS_CHROMEOS) || defined(OS_WIN) || \ | 590 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ManagedStorageEvents) { |
| 589 (defined(OS_LINUX) && defined(USE_AURA)) | |
| 590 // Flakily times out. http://crbug.com/171477 | |
| 591 #define MAYBE_ManagedStorageEvents DISABLED_ManagedStorageEvents | |
| 592 #else | |
| 593 #define MAYBE_ManagedStorageEvents ManagedStorageEvents | |
| 594 #endif | |
| 595 | |
| 596 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, MAYBE_ManagedStorageEvents) { | |
| 597 // This test runs after PRE_ManagedStorageEvents without having deleted the | 591 // This test runs after PRE_ManagedStorageEvents without having deleted the |
| 598 // profile, so the extension is still around. While the browser restarted the | 592 // profile, so the extension is still around. While the browser restarted the |
| 599 // policy went back to the empty default, and so the extension should receive | 593 // policy went back to the empty default, and so the extension should receive |
| 600 // the corresponding change events. | 594 // the corresponding change events. |
| 601 | 595 |
| 602 ResultCatcher catcher; | 596 ResultCatcher catcher; |
| 603 | 597 |
| 604 // Verify that the test extension is still installed. | 598 // Verify that the test extension is still installed. |
| 605 const Extension* extension = GetSingleLoadedExtension(); | 599 const Extension* extension = GetSingleLoadedExtension(); |
| 606 ASSERT_TRUE(extension); | 600 ASSERT_TRUE(extension); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 619 SettingsFrontend* frontend = | 613 SettingsFrontend* frontend = |
| 620 browser()->profile()->GetExtensionService()->settings_frontend(); | 614 browser()->profile()->GetExtensionService()->settings_frontend(); |
| 621 frontend->DisableStorageForTesting(MANAGED); | 615 frontend->DisableStorageForTesting(MANAGED); |
| 622 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); | 616 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); |
| 623 // Now run the extension. | 617 // Now run the extension. |
| 624 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) | 618 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) |
| 625 << message_; | 619 << message_; |
| 626 } | 620 } |
| 627 | 621 |
| 628 } // namespace extensions | 622 } // namespace extensions |
| OLD | NEW |