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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service_browsertest.cc

Issue 2194193002: Fix ArcBridgeBootstrap race issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 2 months 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
« no previous file with comments | « no previous file | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/test/base/in_process_browser_test.h" 26 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
28 #include "chromeos/chromeos_switches.h" 28 #include "chromeos/chromeos_switches.h"
29 #include "chromeos/dbus/dbus_thread_manager.h" 29 #include "chromeos/dbus/dbus_thread_manager.h"
30 #include "chromeos/dbus/fake_session_manager_client.h" 30 #include "chromeos/dbus/fake_session_manager_client.h"
31 #include "chromeos/dbus/session_manager_client.h" 31 #include "chromeos/dbus/session_manager_client.h"
32 #include "components/arc/arc_bridge_service_impl.h" 32 #include "components/arc/arc_bridge_service_impl.h"
33 #include "components/arc/arc_service_manager.h" 33 #include "components/arc/arc_service_manager.h"
34 #include "components/arc/test/fake_arc_bridge_bootstrap.h" 34 #include "components/arc/test/fake_arc_bridge_bootstrap.h"
35 #include "components/arc/test/fake_arc_bridge_instance.h"
36 #include "components/policy/core/common/policy_switches.h" 35 #include "components/policy/core/common/policy_switches.h"
37 #include "components/prefs/pref_member.h" 36 #include "components/prefs/pref_member.h"
38 #include "components/prefs/pref_service.h" 37 #include "components/prefs/pref_service.h"
39 #include "components/signin/core/account_id/account_id.h" 38 #include "components/signin/core/account_id/account_id.h"
40 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" 39 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
41 #include "components/user_manager/user_manager.h" 40 #include "components/user_manager/user_manager.h"
42 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
43 #include "url/gurl.h" 42 #include "url/gurl.h"
44 43
45 namespace { 44 namespace {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Enable ARC. 132 // Enable ARC.
134 command_line->AppendSwitch(chromeos::switches::kEnableArc); 133 command_line->AppendSwitch(chromeos::switches::kEnableArc);
135 chromeos::FakeSessionManagerClient* const fake_session_manager_client = 134 chromeos::FakeSessionManagerClient* const fake_session_manager_client =
136 new chromeos::FakeSessionManagerClient; 135 new chromeos::FakeSessionManagerClient;
137 fake_session_manager_client->set_arc_available(true); 136 fake_session_manager_client->set_arc_available(true);
138 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( 137 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
139 std::unique_ptr<chromeos::SessionManagerClient>( 138 std::unique_ptr<chromeos::SessionManagerClient>(
140 fake_session_manager_client)); 139 fake_session_manager_client));
141 140
142 // Mock out ARC bridge. 141 // Mock out ARC bridge.
143 fake_arc_bridge_instance_.reset(new FakeArcBridgeInstance); 142 auto service = base::MakeUnique<ArcBridgeServiceImpl>();
144 ArcServiceManager::SetArcBridgeServiceForTesting( 143 service->SetArcBridgeBootstrapFactoryForTesting(
145 base::MakeUnique<ArcBridgeServiceImpl>(base::WrapUnique( 144 base::Bind(FakeArcBridgeBootstrap::Create));
146 new FakeArcBridgeBootstrap(fake_arc_bridge_instance_.get())))); 145 ArcServiceManager::SetArcBridgeServiceForTesting(std::move(service));
147 } 146 }
148 147
149 void SetUpOnMainThread() override { 148 void SetUpOnMainThread() override {
150 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler( 149 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler(
151 new chromeos::FakeChromeUserManager)); 150 new chromeos::FakeChromeUserManager));
152 // Init ArcAuthService for testing. 151 // Init ArcAuthService for testing.
153 ArcAuthService::DisableUIForTesting(); 152 ArcAuthService::DisableUIForTesting();
154 ArcAuthService::EnableCheckAndroidManagementForTesting(); 153 ArcAuthService::EnableCheckAndroidManagementForTesting();
155 154
156 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 155 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void set_profile_name(const std::string& username) { 198 void set_profile_name(const std::string& username) {
200 profile_->set_profile_name(username); 199 profile_->set_profile_name(username);
201 } 200 }
202 201
203 Profile* profile() { return profile_.get(); } 202 Profile* profile() { return profile_.get(); }
204 203
205 FakeProfileOAuth2TokenService* token_service() { return token_service_; } 204 FakeProfileOAuth2TokenService* token_service() { return token_service_; }
206 205
207 private: 206 private:
208 std::unique_ptr<policy::LocalPolicyTestServer> test_server_; 207 std::unique_ptr<policy::LocalPolicyTestServer> test_server_;
209 std::unique_ptr<FakeArcBridgeInstance> fake_arc_bridge_instance_;
210 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; 208 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
211 base::ScopedTempDir temp_dir_; 209 base::ScopedTempDir temp_dir_;
212 std::unique_ptr<TestingProfile> profile_; 210 std::unique_ptr<TestingProfile> profile_;
213 FakeProfileOAuth2TokenService* token_service_; 211 FakeProfileOAuth2TokenService* token_service_;
214 212
215 DISALLOW_COPY_AND_ASSIGN(ArcAuthServiceTest); 213 DISALLOW_COPY_AND_ASSIGN(ArcAuthServiceTest);
216 }; 214 };
217 215
218 IN_PROC_BROWSER_TEST_F(ArcAuthServiceTest, ConsumerAccount) { 216 IN_PROC_BROWSER_TEST_F(ArcAuthServiceTest, ConsumerAccount) {
219 PrefService* const prefs = profile()->GetPrefs(); 217 PrefService* const prefs = profile()->GetPrefs();
(...skipping 27 matching lines...) Expand all
247 245
248 prefs->SetBoolean(prefs::kArcEnabled, true); 246 prefs->SetBoolean(prefs::kArcEnabled, true);
249 token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken, 247 token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken,
250 base::Time::Max()); 248 base::Time::Max());
251 ArcAuthServiceShutdownObserver observer; 249 ArcAuthServiceShutdownObserver observer;
252 observer.Wait(); 250 observer.Wait();
253 ASSERT_EQ(ArcAuthService::State::STOPPED, ArcAuthService::Get()->state()); 251 ASSERT_EQ(ArcAuthService::State::STOPPED, ArcAuthService::Get()->state());
254 } 252 }
255 253
256 } // namespace arc 254 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698