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

Side by Side Diff: chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc

Issue 86003002: Enable cloud policy for extensions by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/extensions/extension_browsertest.h" 13 #include "chrome/browser/extensions/extension_browsertest.h"
14 #include "chrome/browser/extensions/extension_test_message_listener.h" 14 #include "chrome/browser/extensions/extension_test_message_listener.h"
15 #include "chrome/browser/policy/browser_policy_connector.h" 15 #include "chrome/browser/policy/browser_policy_connector.h"
16 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 16 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
17 #include "chrome/browser/policy/cloud/mock_cloud_policy_client.h" 17 #include "chrome/browser/policy/cloud/mock_cloud_policy_client.h"
18 #include "chrome/browser/policy/policy_service.h" 18 #include "chrome/browser/policy/policy_service.h"
19 #include "chrome/browser/policy/profile_policy_connector.h" 19 #include "chrome/browser/policy/profile_policy_connector.h"
20 #include "chrome/browser/policy/profile_policy_connector_factory.h" 20 #include "chrome/browser/policy/profile_policy_connector_factory.h"
21 #include "chrome/browser/policy/proto/cloud/chrome_extension_policy.pb.h" 21 #include "chrome/browser/policy/proto/cloud/chrome_extension_policy.pb.h"
22 #include "chrome/browser/policy/test/local_policy_test_server.h" 22 #include "chrome/browser/policy/test/local_policy_test_server.h"
23 #include "chrome/browser/policy/test/policy_test_utils.h" 23 #include "chrome/browser/policy/test/policy_test_utils.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "components/policy/core/common/policy_switches.h"
28 #include "extensions/common/extension.h" 27 #include "extensions/common/extension.h"
29 #include "net/url_request/url_request_context_getter.h" 28 #include "net/url_request/url_request_context_getter.h"
30 #include "policy/proto/cloud_policy.pb.h" 29 #include "policy/proto/cloud_policy.pb.h"
31 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
32 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
33 32
34 #if defined(OS_CHROMEOS) 33 #if defined(OS_CHROMEOS)
35 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 34 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
36 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 35 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
37 #include "chromeos/chromeos_switches.h" 36 #include "chromeos/chromeos_switches.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 98
100 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 99 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
101 test_server_.RegisterClient(kDMToken, kDeviceID); 100 test_server_.RegisterClient(kDMToken, kDeviceID);
102 EXPECT_TRUE(test_server_.UpdatePolicyData( 101 EXPECT_TRUE(test_server_.UpdatePolicyData(
103 dm_protocol::kChromeExtensionPolicyType, kTestExtension, kTestPolicy)); 102 dm_protocol::kChromeExtensionPolicyType, kTestExtension, kTestPolicy));
104 ASSERT_TRUE(test_server_.Start()); 103 ASSERT_TRUE(test_server_.Start());
105 104
106 std::string url = test_server_.GetServiceURL().spec(); 105 std::string url = test_server_.GetServiceURL().spec();
107 CommandLine* command_line = CommandLine::ForCurrentProcess(); 106 CommandLine* command_line = CommandLine::ForCurrentProcess();
108 command_line->AppendSwitchASCII(::switches::kDeviceManagementUrl, url); 107 command_line->AppendSwitchASCII(::switches::kDeviceManagementUrl, url);
109 command_line->AppendSwitch(switches::kEnableComponentCloudPolicy);
110 108
111 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); 109 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
112 } 110 }
113 111
114 virtual void SetUpOnMainThread() OVERRIDE { 112 virtual void SetUpOnMainThread() OVERRIDE {
115 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) 113 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service()))
116 << "Pre-existing policies in this machine will make this test fail."; 114 << "Pre-existing policies in this machine will make this test fail.";
117 115
118 // Install the initial extension. 116 // Install the initial extension.
119 ExtensionTestMessageListener ready_listener("ready", true); 117 ExtensionTestMessageListener ready_listener("ready", true);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 LoadExtension(kTestExtension2Path); 240 LoadExtension(kTestExtension2Path);
243 ASSERT_TRUE(extension2.get()); 241 ASSERT_TRUE(extension2.get());
244 ASSERT_EQ(kTestExtension2, extension2->id()); 242 ASSERT_EQ(kTestExtension2, extension2->id());
245 243
246 // This extension only sends the 'policy' signal once it receives the policy, 244 // This extension only sends the 'policy' signal once it receives the policy,
247 // and after verifying it has the expected value. Otherwise it sends 'fail'. 245 // and after verifying it has the expected value. Otherwise it sends 'fail'.
248 EXPECT_TRUE(result_listener.WaitUntilSatisfied()); 246 EXPECT_TRUE(result_listener.WaitUntilSatisfied());
249 } 247 }
250 248
251 } // namespace policy 249 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/cloud_policy_manager.cc ('k') | components/policy/core/common/policy_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698