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

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

Issue 72793003: ComponentCloudPolicyService tracks the signin state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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"
27 #include "extensions/common/extension.h" 28 #include "extensions/common/extension.h"
28 #include "net/url_request/url_request_context_getter.h" 29 #include "net/url_request/url_request_context_getter.h"
29 #include "policy/proto/cloud_policy.pb.h" 30 #include "policy/proto/cloud_policy.pb.h"
30 #include "testing/gmock/include/gmock/gmock.h" 31 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 33
33 #if defined(OS_CHROMEOS) 34 #if defined(OS_CHROMEOS)
34 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 35 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
35 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 36 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
36 #include "chrome/common/chrome_paths.h" 37 #include "chrome/common/chrome_paths.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 ComponentCloudPolicyTest() {} 89 ComponentCloudPolicyTest() {}
89 virtual ~ComponentCloudPolicyTest() {} 90 virtual ~ComponentCloudPolicyTest() {}
90 91
91 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 92 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
92 ExtensionBrowserTest::SetUpCommandLine(command_line); 93 ExtensionBrowserTest::SetUpCommandLine(command_line);
93 #if defined(OS_CHROMEOS) 94 #if defined(OS_CHROMEOS)
94 // ExtensionBrowserTest sets the login users to a non-managed value; 95 // ExtensionBrowserTest sets the login users to a non-managed value;
95 // replace it. This is the default username sent in policy blobs from the 96 // replace it. This is the default username sent in policy blobs from the
96 // testserver. 97 // testserver.
97 command_line->AppendSwitchASCII( 98 command_line->AppendSwitchASCII(
98 chromeos::switches::kLoginUser, "user@example.com"); 99 ::chromeos::switches::kLoginUser, "user@example.com");
99 #endif 100 #endif
100 } 101 }
101 102
102 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 103 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
103 test_server_.RegisterClient(kDMToken, kDeviceID); 104 test_server_.RegisterClient(kDMToken, kDeviceID);
104 EXPECT_TRUE(test_server_.UpdatePolicyData( 105 EXPECT_TRUE(test_server_.UpdatePolicyData(
105 dm_protocol::kChromeExtensionPolicyType, kTestExtension, kTestPolicy)); 106 dm_protocol::kChromeExtensionPolicyType, kTestExtension, kTestPolicy));
106 ASSERT_TRUE(test_server_.Start()); 107 ASSERT_TRUE(test_server_.Start());
107 108
108 std::string url = test_server_.GetServiceURL().spec(); 109 std::string url = test_server_.GetServiceURL().spec();
109 CommandLine* command_line = CommandLine::ForCurrentProcess(); 110 CommandLine* command_line = CommandLine::ForCurrentProcess();
110 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); 111 command_line->AppendSwitchASCII(::switches::kDeviceManagementUrl, url);
111 command_line->AppendSwitch(switches::kEnableComponentCloudPolicy); 112 command_line->AppendSwitch(switches::kEnableComponentCloudPolicy);
112 113
113 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); 114 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
114 } 115 }
115 116
116 virtual void SetUpOnMainThread() OVERRIDE { 117 virtual void SetUpOnMainThread() OVERRIDE {
117 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) 118 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service()))
118 << "Pre-existing policies in this machine will make this test fail."; 119 << "Pre-existing policies in this machine will make this test fail.";
119 120
120 // Install the initial extension. 121 // Install the initial extension.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 ASSERT_EQ(kTestExtension2, extension2->id()); 250 ASSERT_EQ(kTestExtension2, extension2->id());
250 251
251 // This extension only sends the 'policy' signal once it receives the policy, 252 // This extension only sends the 'policy' signal once it receives the policy,
252 // and after verifying it has the expected value. Otherwise it sends 'fail'. 253 // and after verifying it has the expected value. Otherwise it sends 'fail'.
253 EXPECT_TRUE(result_listener.WaitUntilSatisfied()); 254 EXPECT_TRUE(result_listener.WaitUntilSatisfied());
254 } 255 }
255 256
256 #endif // OS_CHROMEOS 257 #endif // OS_CHROMEOS
257 258
258 } // namespace policy 259 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698