| 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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "base/version.h" | 11 #include "base/version.h" |
| 12 #include "chrome/browser/extensions/external_policy_loader.h" | 12 #include "chrome/browser/extensions/external_policy_loader.h" |
| 13 #include "chrome/browser/extensions/external_provider_impl.h" | 13 #include "chrome/browser/extensions/external_provider_impl.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/testing_pref_service_syncable.h" | 15 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 18 #include "extensions/browser/external_provider_interface.h" | 18 #include "extensions/browser/external_provider_interface.h" |
| 19 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 20 #include "extensions/common/manifest.h" | 20 #include "extensions/common/manifest.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 | 24 |
| 25 namespace extensions { | 25 namespace extensions { |
| 26 | 26 |
| 27 class ExternalPolicyLoaderTest : public testing::Test { | 27 class ExternalPolicyLoaderTest : public testing::Test { |
| 28 public: | 28 public: |
| 29 ExternalPolicyLoaderTest() | 29 ExternalPolicyLoaderTest() : ui_thread_(BrowserThread::UI, &loop_) { |
| 30 : loop_(base::MessageLoop::TYPE_IO), | |
| 31 ui_thread_(BrowserThread::UI, &loop_) { | |
| 32 } | 30 } |
| 33 | 31 |
| 34 virtual ~ExternalPolicyLoaderTest() {} | 32 virtual ~ExternalPolicyLoaderTest() {} |
| 35 | 33 |
| 36 private: | 34 private: |
| 37 // We need these to satisfy BrowserThread::CurrentlyOn(BrowserThread::UI) | 35 // We need these to satisfy BrowserThread::CurrentlyOn(BrowserThread::UI) |
| 38 // checks in ExternalProviderImpl. | 36 // checks in ExternalProviderImpl. |
| 39 base::MessageLoop loop_; | 37 base::MessageLoopForIO loop_; |
| 40 content::TestBrowserThread ui_thread_; | 38 content::TestBrowserThread ui_thread_; |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 class MockExternalPolicyProviderVisitor | 41 class MockExternalPolicyProviderVisitor |
| 44 : public ExternalProviderInterface::VisitorInterface { | 42 : public ExternalProviderInterface::VisitorInterface { |
| 45 public: | 43 public: |
| 46 MockExternalPolicyProviderVisitor() { | 44 MockExternalPolicyProviderVisitor() { |
| 47 } | 45 } |
| 48 | 46 |
| 49 // Initialize a provider with |policy_forcelist|, and check that it installs | 47 // Initialize a provider with |policy_forcelist|, and check that it installs |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 forced_extensions.SetString("invalid", "http://www.example.com/crx"); | 140 forced_extensions.SetString("invalid", "http://www.example.com/crx"); |
| 143 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", | 141 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", |
| 144 std::string()); | 142 std::string()); |
| 145 forced_extensions.SetString("invalid", "bad"); | 143 forced_extensions.SetString("invalid", "bad"); |
| 146 | 144 |
| 147 MockExternalPolicyProviderVisitor mv; | 145 MockExternalPolicyProviderVisitor mv; |
| 148 mv.Visit(forced_extensions, expected_extensions); | 146 mv.Visit(forced_extensions, expected_extensions); |
| 149 } | 147 } |
| 150 | 148 |
| 151 } // namespace extensions | 149 } // namespace extensions |
| OLD | NEW |