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 "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 factories.push_back( | 92 factories.push_back( |
93 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), | 93 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), |
94 BuildFakeProfileOAuth2TokenService)); | 94 BuildFakeProfileOAuth2TokenService)); |
95 profile_ = profile_manager_->CreateTestingProfile( | 95 profile_ = profile_manager_->CreateTestingProfile( |
96 chrome::kInitialProfile, | 96 chrome::kInitialProfile, |
97 scoped_ptr<PrefServiceSyncable>(), | 97 scoped_ptr<PrefServiceSyncable>(), |
98 base::UTF8ToUTF16(""), | 98 base::UTF8ToUTF16(""), |
99 0, | 99 0, |
100 std::string(), | 100 std::string(), |
101 factories); | 101 factories); |
102 signin_profile_ = profile_manager_->CreateTestingProfile(kSigninProfile); | |
103 signin_profile_->ForceIncognito(true); | |
104 // Usually the signin Profile and the main Profile are separate, but since | 102 // Usually the signin Profile and the main Profile are separate, but since |
105 // the signin Profile is an OTR Profile then for this test it suffices to | 103 // the signin Profile is an OTR Profile then for this test it suffices to |
106 // attach it to the main Profile. | 104 // attach it to the main Profile. |
107 profile_->SetOffTheRecordProfile(scoped_ptr<Profile>(signin_profile_)); | 105 signin_profile_ = TestingProfile::Builder().BuildIncognito(profile_); |
108 signin_profile_->SetOriginalProfile(profile_); | |
109 ASSERT_EQ(signin_profile_, chromeos::ProfileHelper::GetSigninProfile()); | 106 ASSERT_EQ(signin_profile_, chromeos::ProfileHelper::GetSigninProfile()); |
110 | 107 |
111 chrome::RegisterLocalState(prefs_.registry()); | 108 chrome::RegisterLocalState(prefs_.registry()); |
112 | 109 |
113 // Set up a policy map for testing. | 110 // Set up a policy map for testing. |
114 policy_map_.Set(key::kHomepageLocation, | 111 policy_map_.Set(key::kHomepageLocation, |
115 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 112 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
116 new base::StringValue("http://chromium.org"), | 113 new base::StringValue("http://chromium.org"), |
117 NULL); | 114 NULL); |
118 policy_map_.Set(key::kChromeOsMultiProfileUserBehavior, | 115 policy_map_.Set(key::kChromeOsMultiProfileUserBehavior, |
(...skipping 30 matching lines...) Expand all Loading... |
149 | 146 |
150 virtual void TearDown() OVERRIDE { | 147 virtual void TearDown() OVERRIDE { |
151 if (token_forwarder_) | 148 if (token_forwarder_) |
152 token_forwarder_->Shutdown(); | 149 token_forwarder_->Shutdown(); |
153 if (manager_) { | 150 if (manager_) { |
154 manager_->RemoveObserver(&observer_); | 151 manager_->RemoveObserver(&observer_); |
155 manager_->Shutdown(); | 152 manager_->Shutdown(); |
156 } | 153 } |
157 signin_profile_ = NULL; | 154 signin_profile_ = NULL; |
158 profile_ = NULL; | 155 profile_ = NULL; |
159 profile_manager_->DeleteTestingProfile(kSigninProfile); | |
160 profile_manager_->DeleteTestingProfile(chrome::kInitialProfile); | 156 profile_manager_->DeleteTestingProfile(chrome::kInitialProfile); |
161 } | 157 } |
162 | 158 |
163 void CreateManager(bool wait_for_fetch, int fetch_timeout) { | 159 void CreateManager(bool wait_for_fetch, int fetch_timeout) { |
164 store_ = new MockCloudPolicyStore(); | 160 store_ = new MockCloudPolicyStore(); |
165 external_data_manager_ = new MockCloudExternalDataManager; | 161 external_data_manager_ = new MockCloudExternalDataManager; |
166 external_data_manager_->SetPolicyStore(store_); | 162 external_data_manager_->SetPolicyStore(store_); |
167 EXPECT_CALL(*store_, Load()); | 163 EXPECT_CALL(*store_, Load()); |
168 manager_.reset(new UserCloudPolicyManagerChromeOS( | 164 manager_.reset(new UserCloudPolicyManagerChromeOS( |
169 scoped_ptr<CloudPolicyStore>(store_), | 165 scoped_ptr<CloudPolicyStore>(store_), |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 582 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
587 EXPECT_TRUE(manager_->core()->client()->is_registered()); | 583 EXPECT_TRUE(manager_->core()->client()->is_registered()); |
588 | 584 |
589 // The refresh scheduler takes care of the initial fetch for unmanaged users. | 585 // The refresh scheduler takes care of the initial fetch for unmanaged users. |
590 // Running the task runner issues the initial fetch. | 586 // Running the task runner issues the initial fetch. |
591 FetchPolicy( | 587 FetchPolicy( |
592 base::Bind(&base::TestSimpleTaskRunner::RunUntilIdle, task_runner_)); | 588 base::Bind(&base::TestSimpleTaskRunner::RunUntilIdle, task_runner_)); |
593 } | 589 } |
594 | 590 |
595 } // namespace policy | 591 } // namespace policy |
OLD | NEW |