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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "chrome/browser/policy/browser_policy_connector.h" | 7 #include "chrome/browser/policy/browser_policy_connector.h" |
8 #include "chrome/browser/policy/mock_cloud_policy_store.h" | 8 #include "chrome/browser/policy/mock_cloud_policy_store.h" |
9 #include "chrome/browser/policy/user_cloud_policy_manager.h" | 9 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
10 #include "chrome/browser/policy/user_policy_signin_service.h" | 10 #include "chrome/browser/policy/user_policy_signin_service.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 namespace policy { | 32 namespace policy { |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 class UserPolicySigninServiceTest : public testing::Test { | 36 class UserPolicySigninServiceTest : public testing::Test { |
37 public: | 37 public: |
38 UserPolicySigninServiceTest() | 38 UserPolicySigninServiceTest() |
39 : loop_(MessageLoop::TYPE_UI), | 39 : loop_(MessageLoop::TYPE_UI), |
40 ui_thread_(content::BrowserThread::UI, &loop_), | 40 ui_thread_(content::BrowserThread::UI, &loop_), |
41 file_thread_(content::BrowserThread::FILE, &loop_) {} | 41 file_thread_(content::BrowserThread::FILE, &loop_), |
| 42 io_thread_(content::BrowserThread::IO, &loop_) {} |
42 | 43 |
43 virtual void SetUp() OVERRIDE { | 44 virtual void SetUp() OVERRIDE { |
44 g_browser_process->browser_policy_connector()->Init(); | 45 g_browser_process->browser_policy_connector()->Init(); |
45 | 46 |
46 local_state_.reset(new TestingPrefService); | 47 local_state_.reset(new TestingPrefService); |
47 chrome::RegisterLocalState(local_state_.get()); | 48 chrome::RegisterLocalState(local_state_.get()); |
48 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( | 49 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( |
49 local_state_.get()); | 50 local_state_.get()); |
50 | 51 |
51 // Create a UserCloudPolicyManager with a MockCloudPolicyStore, and build a | 52 // Create a UserCloudPolicyManager with a MockCloudPolicyStore, and build a |
(...skipping 25 matching lines...) Expand all Loading... |
77 testing_browser_process->SetBrowserPolicyConnector(NULL); | 78 testing_browser_process->SetBrowserPolicyConnector(NULL); |
78 base::RunLoop run_loop; | 79 base::RunLoop run_loop; |
79 run_loop.RunUntilIdle(); | 80 run_loop.RunUntilIdle(); |
80 } | 81 } |
81 | 82 |
82 scoped_ptr<TestingProfile> profile_; | 83 scoped_ptr<TestingProfile> profile_; |
83 // Weak pointer to a MockCloudPolicyStore - lifetime is managed by the | 84 // Weak pointer to a MockCloudPolicyStore - lifetime is managed by the |
84 // UserCloudPolicyManager. | 85 // UserCloudPolicyManager. |
85 MockCloudPolicyStore* mock_store_; | 86 MockCloudPolicyStore* mock_store_; |
86 | 87 |
87 // BrowserPolicyConnector wants to initialize various components | 88 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free |
88 // asynchronously via tasks, so create a fake thread here. | 89 // various components asynchronously via tasks, so create fake threads here. |
89 MessageLoop loop_; | 90 MessageLoop loop_; |
90 content::TestBrowserThread ui_thread_; | 91 content::TestBrowserThread ui_thread_; |
91 content::TestBrowserThread file_thread_; | 92 content::TestBrowserThread file_thread_; |
| 93 content::TestBrowserThread io_thread_; |
92 | 94 |
93 scoped_ptr<TestingPrefService> local_state_; | 95 scoped_ptr<TestingPrefService> local_state_; |
94 }; | 96 }; |
95 | 97 |
96 TEST_F(UserPolicySigninServiceTest, InitWhileSignedOut) { | 98 TEST_F(UserPolicySigninServiceTest, InitWhileSignedOut) { |
97 // Make sure user is not signed in. | 99 // Make sure user is not signed in. |
98 ASSERT_TRUE(SigninManagerFactory::GetForProfile(profile_.get())-> | 100 ASSERT_TRUE(SigninManagerFactory::GetForProfile(profile_.get())-> |
99 GetAuthenticatedUsername().empty()); | 101 GetAuthenticatedUsername().empty()); |
100 | 102 |
101 // Let the SigninService know that the profile has been created. | 103 // Let the SigninService know that the profile has been created. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Now sign out. | 164 // Now sign out. |
163 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); | 165 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); |
164 | 166 |
165 // UserCloudPolicyManager should be shut down. | 167 // UserCloudPolicyManager should be shut down. |
166 ASSERT_FALSE(profile_->GetUserCloudPolicyManager()->cloud_policy_service()); | 168 ASSERT_FALSE(profile_->GetUserCloudPolicyManager()->cloud_policy_service()); |
167 } | 169 } |
168 | 170 |
169 } // namespace | 171 } // namespace |
170 | 172 |
171 } // namespace policy | 173 } // namespace policy |
OLD | NEW |