| 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | |
| 11 #include "base/values.h" | 10 #include "base/values.h" |
| 12 #include "base/version.h" | 11 #include "base/version.h" |
| 13 #include "chrome/browser/extensions/extension_management.h" | 12 #include "chrome/browser/extensions/extension_management.h" |
| 14 #include "chrome/browser/extensions/external_policy_loader.h" | 13 #include "chrome/browser/extensions/external_policy_loader.h" |
| 15 #include "chrome/browser/extensions/external_provider_impl.h" | 14 #include "chrome/browser/extensions/external_provider_impl.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 17 #include "components/sync_preferences/testing_pref_service_syncable.h" | 16 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 18 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 18 #include "content/public/test/test_browser_thread_bundle.h" |
| 19 #include "extensions/browser/external_install_info.h" | 19 #include "extensions/browser/external_install_info.h" |
| 20 #include "extensions/browser/external_provider_interface.h" | 20 #include "extensions/browser/external_provider_interface.h" |
| 21 #include "extensions/browser/pref_names.h" | 21 #include "extensions/browser/pref_names.h" |
| 22 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 23 #include "extensions/common/manifest.h" | 23 #include "extensions/common/manifest.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 using content::BrowserThread; | 26 using content::BrowserThread; |
| 27 | 27 |
| 28 namespace extensions { | 28 namespace extensions { |
| 29 | 29 |
| 30 class ExternalPolicyLoaderTest : public testing::Test { | 30 class ExternalPolicyLoaderTest : public testing::Test { |
| 31 public: | 31 public: |
| 32 ExternalPolicyLoaderTest() : ui_thread_(BrowserThread::UI, &loop_) { | 32 ExternalPolicyLoaderTest() |
| 33 } | 33 : test_browser_thread_bundle_( |
| 34 content::TestBrowserThreadBundle::IO_MAINLOOP) {} |
| 34 | 35 |
| 35 ~ExternalPolicyLoaderTest() override {} | 36 ~ExternalPolicyLoaderTest() override {} |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 // We need these to satisfy BrowserThread::CurrentlyOn(BrowserThread::UI) | 39 // Needed to satisfy BrowserThread::CurrentlyOn(BrowserThread::UI) checks in |
| 39 // checks in ExternalProviderImpl. | 40 // ExternalProviderImpl. |
| 40 base::MessageLoopForIO loop_; | 41 content::TestBrowserThreadBundle test_browser_thread_bundle_; |
| 41 content::TestBrowserThread ui_thread_; | |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 class MockExternalPolicyProviderVisitor | 44 class MockExternalPolicyProviderVisitor |
| 45 : public ExternalProviderInterface::VisitorInterface { | 45 : public ExternalProviderInterface::VisitorInterface { |
| 46 public: | 46 public: |
| 47 MockExternalPolicyProviderVisitor() { | 47 MockExternalPolicyProviderVisitor() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Initialize a provider with |policy_forcelist|, and check that it installs | 50 // Initialize a provider with |policy_forcelist|, and check that it installs |
| 51 // exactly the extensions specified in |expected_extensions|. | 51 // exactly the extensions specified in |expected_extensions|. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 forced_extensions.SetString("invalid", "http://www.example.com/crx"); | 150 forced_extensions.SetString("invalid", "http://www.example.com/crx"); |
| 151 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", | 151 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", |
| 152 std::string()); | 152 std::string()); |
| 153 forced_extensions.SetString("invalid", "bad"); | 153 forced_extensions.SetString("invalid", "bad"); |
| 154 | 154 |
| 155 MockExternalPolicyProviderVisitor mv; | 155 MockExternalPolicyProviderVisitor mv; |
| 156 mv.Visit(forced_extensions, expected_extensions); | 156 mv.Visit(forced_extensions, expected_extensions); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace extensions | 159 } // namespace extensions |
| OLD | NEW |