| OLD | NEW |
| 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 #include <tuple> | 7 #include <tuple> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 27 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 28 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 28 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 29 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 29 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 30 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 30 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 31 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 31 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 32 #include "chrome/browser/policy/profile_policy_connector.h" | 32 #include "chrome/browser/policy/profile_policy_connector.h" |
| 33 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 33 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 34 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 34 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 36 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 37 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 37 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 38 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 38 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/test/base/testing_profile.h" | 40 #include "chrome/test/base/testing_profile.h" |
| 40 #include "chromeos/chromeos_switches.h" | 41 #include "chromeos/chromeos_switches.h" |
| 41 #include "chromeos/dbus/dbus_thread_manager.h" | 42 #include "chromeos/dbus/dbus_thread_manager.h" |
| 42 #include "chromeos/dbus/fake_session_manager_client.h" | 43 #include "chromeos/dbus/fake_session_manager_client.h" |
| 43 #include "components/arc/arc_service_manager.h" | 44 #include "components/arc/arc_service_manager.h" |
| 44 #include "components/arc/arc_session_runner.h" | 45 #include "components/arc/arc_session_runner.h" |
| 45 #include "components/arc/arc_util.h" | 46 #include "components/arc/arc_util.h" |
| 46 #include "components/arc/test/fake_arc_session.h" | 47 #include "components/arc/test/fake_arc_session.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 content::TestBrowserThreadBundle thread_bundle_; | 196 content::TestBrowserThreadBundle thread_bundle_; |
| 196 std::unique_ptr<TestingProfile> profile_; | 197 std::unique_ptr<TestingProfile> profile_; |
| 197 std::unique_ptr<ArcServiceManager> arc_service_manager_; | 198 std::unique_ptr<ArcServiceManager> arc_service_manager_; |
| 198 std::unique_ptr<ArcSessionManager> arc_session_manager_; | 199 std::unique_ptr<ArcSessionManager> arc_session_manager_; |
| 199 chromeos::ScopedUserManagerEnabler user_manager_enabler_; | 200 chromeos::ScopedUserManagerEnabler user_manager_enabler_; |
| 200 base::ScopedTempDir temp_dir_; | 201 base::ScopedTempDir temp_dir_; |
| 201 | 202 |
| 202 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTestBase); | 203 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTestBase); |
| 203 }; | 204 }; |
| 204 | 205 |
| 205 class ArcSessionManagerTest : public ArcSessionManagerTestBase { | 206 // Intermediate class so that the children can inject test parameter freely. |
| 207 class AbstractArcSessionManagerTest : public ArcSessionManagerTestBase { |
| 206 public: | 208 public: |
| 207 ArcSessionManagerTest() = default; | 209 AbstractArcSessionManagerTest() = default; |
| 208 | |
| 209 void SetUp() override { | 210 void SetUp() override { |
| 210 ArcSessionManagerTestBase::SetUp(); | 211 ArcSessionManagerTestBase::SetUp(); |
| 212 if (ShouldAlwaysStartArcInTest()) |
| 213 SetAlwaysStartArcForTesting(); |
| 211 | 214 |
| 212 const AccountId account_id(AccountId::FromUserEmailGaiaId( | 215 const AccountId account_id(AccountId::FromUserEmailGaiaId( |
| 213 profile()->GetProfileUserName(), "1234567890")); | 216 profile()->GetProfileUserName(), "1234567890")); |
| 214 GetFakeUserManager()->AddUser(account_id); | 217 GetFakeUserManager()->AddUser(account_id); |
| 215 GetFakeUserManager()->LoginUser(account_id); | 218 GetFakeUserManager()->LoginUser(account_id); |
| 216 } | 219 } |
| 217 | 220 |
| 221 protected: |
| 222 virtual bool ShouldAlwaysStartArcInTest() = 0; |
| 223 |
| 224 private: |
| 225 DISALLOW_COPY_AND_ASSIGN(AbstractArcSessionManagerTest); |
| 226 }; |
| 227 |
| 228 class ArcSessionManagerTest : public AbstractArcSessionManagerTest, |
| 229 public ::testing::WithParamInterface<bool> { |
| 230 public: |
| 231 ArcSessionManagerTest() = default; |
| 232 |
| 233 protected: |
| 234 bool ShouldAlwaysStartArcInTest() override { return GetParam(); } |
| 235 |
| 218 private: | 236 private: |
| 219 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTest); | 237 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTest); |
| 220 }; | 238 }; |
| 221 | 239 |
| 222 TEST_F(ArcSessionManagerTest, PrefChangeTriggersService) { | 240 INSTANTIATE_TEST_CASE_P(, ArcSessionManagerTest, ::testing::Bool()); |
| 241 |
| 242 TEST_P(ArcSessionManagerTest, PrefChangeTriggersService) { |
| 243 // TODO(victorhsieh): Implement opt-in and opt-out flow. |
| 244 if (ShouldAlwaysStartArc()) |
| 245 return; |
| 246 |
| 223 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, | 247 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, |
| 224 arc_session_manager()->state()); | 248 arc_session_manager()->state()); |
| 225 | 249 |
| 226 PrefService* const pref = profile()->GetPrefs(); | 250 PrefService* const pref = profile()->GetPrefs(); |
| 227 ASSERT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 251 ASSERT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 228 | 252 |
| 229 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 253 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 230 | 254 |
| 231 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); | 255 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); |
| 232 | 256 |
| 233 pref->SetBoolean(prefs::kArcEnabled, true); | 257 pref->SetBoolean(prefs::kArcEnabled, true); |
| 234 base::RunLoop().RunUntilIdle(); | 258 base::RunLoop().RunUntilIdle(); |
| 235 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 259 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 236 arc_session_manager()->state()); | 260 arc_session_manager()->state()); |
| 237 | 261 |
| 238 pref->SetBoolean(prefs::kArcEnabled, false); | 262 pref->SetBoolean(prefs::kArcEnabled, false); |
| 239 | 263 |
| 240 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); | 264 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); |
| 241 | 265 |
| 242 // Correctly stop service. | 266 // Correctly stop service. |
| 243 arc_session_manager()->Shutdown(); | 267 arc_session_manager()->Shutdown(); |
| 244 } | 268 } |
| 245 | 269 |
| 246 TEST_F(ArcSessionManagerTest, DisabledForEphemeralDataUsers) { | 270 TEST_P(ArcSessionManagerTest, DisabledForEphemeralDataUsers) { |
| 247 PrefService* const prefs = profile()->GetPrefs(); | 271 PrefService* const prefs = profile()->GetPrefs(); |
| 248 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 272 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 249 prefs->SetBoolean(prefs::kArcEnabled, true); | 273 prefs->SetBoolean(prefs::kArcEnabled, true); |
| 250 | 274 |
| 251 chromeos::FakeChromeUserManager* const fake_user_manager = | 275 chromeos::FakeChromeUserManager* const fake_user_manager = |
| 252 GetFakeUserManager(); | 276 GetFakeUserManager(); |
| 253 | 277 |
| 254 fake_user_manager->AddUser(fake_user_manager->GetGuestAccountId()); | 278 fake_user_manager->AddUser(fake_user_manager->GetGuestAccountId()); |
| 255 fake_user_manager->SwitchActiveUser(fake_user_manager->GetGuestAccountId()); | 279 fake_user_manager->SwitchActiveUser(fake_user_manager->GetGuestAccountId()); |
| 256 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 280 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 281 fake_user_manager->RemoveUserFromList(not_in_list_account_id); | 305 fake_user_manager->RemoveUserFromList(not_in_list_account_id); |
| 282 arc_session_manager()->Shutdown(); | 306 arc_session_manager()->Shutdown(); |
| 283 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 307 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 284 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, | 308 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, |
| 285 arc_session_manager()->state()); | 309 arc_session_manager()->state()); |
| 286 | 310 |
| 287 // Correctly stop service. | 311 // Correctly stop service. |
| 288 arc_session_manager()->Shutdown(); | 312 arc_session_manager()->Shutdown(); |
| 289 } | 313 } |
| 290 | 314 |
| 291 TEST_F(ArcSessionManagerTest, BaseWorkflow) { | 315 TEST_P(ArcSessionManagerTest, BaseWorkflow) { |
| 316 // See BaseWorkflowOnPersistentArc for Persistent ARC flow. |
| 317 if (ShouldAlwaysStartArc()) |
| 318 return; |
| 319 |
| 292 ASSERT_TRUE(arc_session_manager()->IsSessionStopped()); | 320 ASSERT_TRUE(arc_session_manager()->IsSessionStopped()); |
| 293 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, | 321 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, |
| 294 arc_session_manager()->state()); | 322 arc_session_manager()->state()); |
| 295 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 323 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 296 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); | 324 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); |
| 297 | 325 |
| 298 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 326 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 299 | 327 |
| 300 // By default ARC is not enabled. | 328 // By default ARC is not enabled. |
| 301 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); | 329 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 base::RunLoop().RunUntilIdle(); | 361 base::RunLoop().RunUntilIdle(); |
| 334 | 362 |
| 335 // UI is disabled in unit tests and this code is unchanged. | 363 // UI is disabled in unit tests and this code is unchanged. |
| 336 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 364 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 337 arc_session_manager()->state()); | 365 arc_session_manager()->state()); |
| 338 | 366 |
| 339 // Correctly stop service. | 367 // Correctly stop service. |
| 340 arc_session_manager()->Shutdown(); | 368 arc_session_manager()->Shutdown(); |
| 341 } | 369 } |
| 342 | 370 |
| 343 TEST_F(ArcSessionManagerTest, CancelFetchingDisablesArc) { | 371 TEST_P(ArcSessionManagerTest, CancelFetchingDisablesArc) { |
| 372 // TODO(victorhsieh): Implement opt-in flow on Persistent ARC. |
| 373 if (ShouldAlwaysStartArc()) |
| 374 return; |
| 375 |
| 344 PrefService* const pref = profile()->GetPrefs(); | 376 PrefService* const pref = profile()->GetPrefs(); |
| 345 | 377 |
| 346 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 378 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 347 pref->SetBoolean(prefs::kArcEnabled, true); | 379 pref->SetBoolean(prefs::kArcEnabled, true); |
| 348 base::RunLoop().RunUntilIdle(); | 380 base::RunLoop().RunUntilIdle(); |
| 349 | 381 |
| 350 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 382 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 351 arc_session_manager()->state()); | 383 arc_session_manager()->state()); |
| 352 | 384 |
| 353 arc_session_manager()->CancelAuthCode(); | 385 arc_session_manager()->CancelAuthCode(); |
| 354 | 386 |
| 355 // Wait until data is removed. | 387 // Wait until data is removed. |
| 356 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); | 388 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); |
| 357 | 389 |
| 358 ASSERT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 390 ASSERT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 359 | 391 |
| 360 // Correctly stop service. | 392 // Correctly stop service. |
| 361 arc_session_manager()->Shutdown(); | 393 arc_session_manager()->Shutdown(); |
| 362 } | 394 } |
| 363 | 395 |
| 364 TEST_F(ArcSessionManagerTest, CloseUIKeepsArcEnabled) { | 396 TEST_P(ArcSessionManagerTest, CloseUIKeepsArcEnabled) { |
| 365 PrefService* const pref = profile()->GetPrefs(); | 397 PrefService* const pref = profile()->GetPrefs(); |
| 366 | 398 |
| 367 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 399 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 368 pref->SetBoolean(prefs::kArcEnabled, true); | 400 pref->SetBoolean(prefs::kArcEnabled, true); |
| 369 base::RunLoop().RunUntilIdle(); | 401 base::RunLoop().RunUntilIdle(); |
| 370 | 402 |
| 371 arc_session_manager()->StartArc(); | 403 arc_session_manager()->StartArc(); |
| 372 | 404 |
| 373 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 405 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 374 | 406 |
| 375 arc_session_manager()->CancelAuthCode(); | 407 arc_session_manager()->CancelAuthCode(); |
| 376 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 408 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 377 ASSERT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); | 409 ASSERT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); |
| 378 | 410 |
| 379 // Correctly stop service. | 411 // Correctly stop service. |
| 380 arc_session_manager()->Shutdown(); | 412 arc_session_manager()->Shutdown(); |
| 381 } | 413 } |
| 382 | 414 |
| 383 TEST_F(ArcSessionManagerTest, EnableDisablesArc) { | 415 TEST_P(ArcSessionManagerTest, EnableDisablesArc) { |
| 384 const PrefService* pref = profile()->GetPrefs(); | 416 const PrefService* pref = profile()->GetPrefs(); |
| 385 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 417 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 386 | 418 |
| 387 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 419 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 388 arc_session_manager()->SetArcPlayStoreEnabled(true); | 420 arc_session_manager()->SetArcPlayStoreEnabled(true); |
| 389 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); | 421 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); |
| 390 arc_session_manager()->SetArcPlayStoreEnabled(false); | 422 arc_session_manager()->SetArcPlayStoreEnabled(false); |
| 391 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 423 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 392 | 424 |
| 393 // Correctly stop service. | 425 // Correctly stop service. |
| 394 arc_session_manager()->Shutdown(); | 426 arc_session_manager()->Shutdown(); |
| 395 } | 427 } |
| 396 | 428 |
| 397 TEST_F(ArcSessionManagerTest, SignInStatus) { | 429 TEST_P(ArcSessionManagerTest, SignInStatus) { |
| 398 PrefService* const prefs = profile()->GetPrefs(); | 430 PrefService* const prefs = profile()->GetPrefs(); |
| 399 | 431 |
| 400 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 432 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 401 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); | 433 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); |
| 402 | 434 |
| 403 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 435 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 404 prefs->SetBoolean(prefs::kArcEnabled, true); | 436 prefs->SetBoolean(prefs::kArcEnabled, true); |
| 405 | 437 |
| 406 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 438 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 407 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 439 if (ShouldAlwaysStartArc()) { |
| 408 arc_session_manager()->state()); | 440 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 441 } else { |
| 442 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 443 arc_session_manager()->state()); |
| 444 } |
| 409 | 445 |
| 410 // Emulate to accept the terms of service. | 446 // Emulate to accept the terms of service. |
| 411 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | 447 prefs->SetBoolean(prefs::kArcTermsAccepted, true); |
| 412 arc_session_manager()->StartArc(); | 448 if (!ShouldAlwaysStartArc()) { |
| 449 arc_session_manager()->StartArc(); |
| 450 } |
| 413 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 451 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 414 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); | 452 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 415 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 453 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 416 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); | 454 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); |
| 417 arc_session_manager()->OnProvisioningFinished(ProvisioningResult::SUCCESS); | 455 arc_session_manager()->OnProvisioningFinished(ProvisioningResult::SUCCESS); |
| 418 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); | 456 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 419 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 457 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 420 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); | 458 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 421 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 459 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 422 | 460 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 436 // On error, UI to send feedback is showing. In that case, | 474 // On error, UI to send feedback is showing. In that case, |
| 437 // the ARC is still necessary to run on background for gathering the logs. | 475 // the ARC is still necessary to run on background for gathering the logs. |
| 438 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); | 476 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 439 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 477 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 440 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); | 478 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 441 | 479 |
| 442 // Correctly stop service. | 480 // Correctly stop service. |
| 443 arc_session_manager()->Shutdown(); | 481 arc_session_manager()->Shutdown(); |
| 444 } | 482 } |
| 445 | 483 |
| 446 TEST_F(ArcSessionManagerTest, DisabledForDeviceLocalAccount) { | 484 TEST_P(ArcSessionManagerTest, DisabledForDeviceLocalAccount) { |
| 447 PrefService* const prefs = profile()->GetPrefs(); | 485 PrefService* const prefs = profile()->GetPrefs(); |
| 448 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 486 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 449 prefs->SetBoolean(prefs::kArcEnabled, true); | 487 prefs->SetBoolean(prefs::kArcEnabled, true); |
| 450 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 488 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 451 arc_session_manager()->StartArc(); | 489 arc_session_manager()->StartArc(); |
| 452 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 490 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 453 | 491 |
| 454 // Create device local account and set it as active. | 492 // Create device local account and set it as active. |
| 455 const std::string email = "device-local-account@fake-email.com"; | 493 const std::string email = "device-local-account@fake-email.com"; |
| 456 TestingProfile::Builder profile_builder; | 494 TestingProfile::Builder profile_builder; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 468 device_local_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); | 506 device_local_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
| 469 arc_session_manager()->OnPrimaryUserProfilePrepared( | 507 arc_session_manager()->OnPrimaryUserProfilePrepared( |
| 470 device_local_profile.get()); | 508 device_local_profile.get()); |
| 471 EXPECT_EQ(ArcSessionManager::State::NOT_INITIALIZED, | 509 EXPECT_EQ(ArcSessionManager::State::NOT_INITIALIZED, |
| 472 arc_session_manager()->state()); | 510 arc_session_manager()->state()); |
| 473 | 511 |
| 474 // Correctly stop service. | 512 // Correctly stop service. |
| 475 arc_session_manager()->Shutdown(); | 513 arc_session_manager()->Shutdown(); |
| 476 } | 514 } |
| 477 | 515 |
| 478 TEST_F(ArcSessionManagerTest, DisabledForNonPrimaryProfile) { | 516 TEST_P(ArcSessionManagerTest, DisabledForNonPrimaryProfile) { |
| 479 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); | 517 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
| 480 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 518 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 481 arc_session_manager()->StartArc(); | 519 arc_session_manager()->StartArc(); |
| 482 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 520 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 483 | 521 |
| 484 // Create a second profile and set it as the active profile. | 522 // Create a second profile and set it as the active profile. |
| 485 const std::string email = "test@example.com"; | 523 const std::string email = "test@example.com"; |
| 486 TestingProfile::Builder profile_builder; | 524 TestingProfile::Builder profile_builder; |
| 487 profile_builder.SetProfileName(email); | 525 profile_builder.SetProfileName(email); |
| 488 std::unique_ptr<TestingProfile> second_profile(profile_builder.Build()); | 526 std::unique_ptr<TestingProfile> second_profile(profile_builder.Build()); |
| 489 const AccountId account_id(AccountId::FromUserEmail(email)); | 527 const AccountId account_id(AccountId::FromUserEmail(email)); |
| 490 GetFakeUserManager()->AddUser(account_id); | 528 GetFakeUserManager()->AddUser(account_id); |
| 491 GetFakeUserManager()->SwitchActiveUser(account_id); | 529 GetFakeUserManager()->SwitchActiveUser(account_id); |
| 492 second_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); | 530 second_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
| 493 | 531 |
| 494 // Check that non-primary user can't use ARC. | 532 // Check that non-primary user can't use ARC. |
| 495 EXPECT_FALSE(chromeos::ProfileHelper::IsPrimaryProfile(second_profile.get())); | 533 EXPECT_FALSE(chromeos::ProfileHelper::IsPrimaryProfile(second_profile.get())); |
| 496 EXPECT_FALSE(ArcAppListPrefs::Get(second_profile.get())); | 534 EXPECT_FALSE(ArcAppListPrefs::Get(second_profile.get())); |
| 497 | 535 |
| 498 arc_session_manager()->Shutdown(); | 536 arc_session_manager()->Shutdown(); |
| 499 } | 537 } |
| 500 | 538 |
| 501 TEST_F(ArcSessionManagerTest, RemoveDataFolder) { | 539 TEST_P(ArcSessionManagerTest, RemoveDataFolder) { |
| 540 // TODO(victorhsieh): Implement data removal on Persistent ARC. |
| 541 if (ShouldAlwaysStartArc()) |
| 542 return; |
| 543 |
| 502 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); | 544 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); |
| 503 // Starting session manager with prefs::kArcEnabled off automatically removes | 545 // Starting session manager with prefs::kArcEnabled off automatically removes |
| 504 // Android's data folder. | 546 // Android's data folder. |
| 505 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 547 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 506 EXPECT_TRUE( | 548 EXPECT_TRUE( |
| 507 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 549 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 508 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, | 550 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, |
| 509 arc_session_manager()->state()); | 551 arc_session_manager()->state()); |
| 510 // Enable ARC. Data is removed asyncronously. At this moment session manager | 552 // Enable ARC. Data is removed asyncronously. At this moment session manager |
| 511 // should be in REMOVING_DATA_DIR state. | 553 // should be in REMOVING_DATA_DIR state. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 586 |
| 545 EXPECT_FALSE( | 587 EXPECT_FALSE( |
| 546 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 588 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 547 | 589 |
| 548 arc_session_manager()->StartArc(); | 590 arc_session_manager()->StartArc(); |
| 549 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 591 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 550 | 592 |
| 551 arc_session_manager()->Shutdown(); | 593 arc_session_manager()->Shutdown(); |
| 552 } | 594 } |
| 553 | 595 |
| 554 TEST_F(ArcSessionManagerTest, IgnoreSecondErrorReporting) { | 596 TEST_P(ArcSessionManagerTest, IgnoreSecondErrorReporting) { |
| 555 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); | 597 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
| 556 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 598 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 557 arc_session_manager()->StartArc(); | 599 arc_session_manager()->StartArc(); |
| 558 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 600 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 559 | 601 |
| 560 // Report some failure that does not stop the bridge. | 602 // Report some failure that does not stop the bridge. |
| 561 arc_session_manager()->OnProvisioningFinished( | 603 arc_session_manager()->OnProvisioningFinished( |
| 562 ProvisioningResult::GMS_SIGN_IN_FAILED); | 604 ProvisioningResult::GMS_SIGN_IN_FAILED); |
| 563 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 605 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 564 | 606 |
| 565 // Try to send another error that stops the bridge if sent first. It should | 607 // Try to send another error that stops the bridge if sent first. It should |
| 566 // be ignored. | 608 // be ignored. |
| 567 arc_session_manager()->OnProvisioningFinished( | 609 arc_session_manager()->OnProvisioningFinished( |
| 568 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); | 610 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); |
| 569 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 611 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 570 | 612 |
| 571 arc_session_manager()->Shutdown(); | 613 arc_session_manager()->Shutdown(); |
| 572 } | 614 } |
| 573 | 615 |
| 574 class ArcSessionManagerPolicyTest | 616 class ArcSessionManagerPolicyTest |
| 575 : public ArcSessionManagerTest, | 617 : public AbstractArcSessionManagerTest, |
| 576 public testing::WithParamInterface<std::tuple<base::Value, base::Value>> { | 618 public testing::WithParamInterface< |
| 619 std::tuple<base::Value, base::Value, bool>> { |
| 577 public: | 620 public: |
| 578 const base::Value& backup_restore_pref_value() const { | 621 const base::Value& backup_restore_pref_value() const { |
| 579 return std::get<0>(GetParam()); | 622 return std::get<0>(GetParam()); |
| 580 } | 623 } |
| 581 | 624 |
| 582 const base::Value& location_service_pref_value() const { | 625 const base::Value& location_service_pref_value() const { |
| 583 return std::get<1>(GetParam()); | 626 return std::get<1>(GetParam()); |
| 584 } | 627 } |
| 628 |
| 629 protected: |
| 630 bool ShouldAlwaysStartArcInTest() override { return std::get<2>(GetParam()); } |
| 585 }; | 631 }; |
| 586 | 632 |
| 587 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) { | 633 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) { |
| 634 // TODO(victorhsieh): Implement opt-in flow. |
| 635 if (ShouldAlwaysStartArc()) |
| 636 return; |
| 637 |
| 588 sync_preferences::TestingPrefServiceSyncable* const prefs = | 638 sync_preferences::TestingPrefServiceSyncable* const prefs = |
| 589 profile()->GetTestingPrefService(); | 639 profile()->GetTestingPrefService(); |
| 590 | 640 |
| 591 // Backup-restore and location-service prefs are off by default. | 641 // Backup-restore and location-service prefs are off by default. |
| 592 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 642 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 593 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted)); | 643 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted)); |
| 594 | 644 |
| 595 // Set ARC to be managed. | 645 // Set ARC to be managed. |
| 596 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true)); | 646 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true)); |
| 597 | 647 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 627 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 677 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 628 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled)); | 678 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 629 | 679 |
| 630 // Stop ARC and shutdown the service. | 680 // Stop ARC and shutdown the service. |
| 631 prefs->RemoveManagedPref(prefs::kArcEnabled); | 681 prefs->RemoveManagedPref(prefs::kArcEnabled); |
| 632 WaitForDataRemoved(ArcSessionManager::State::STOPPED); | 682 WaitForDataRemoved(ArcSessionManager::State::STOPPED); |
| 633 arc_session_manager()->Shutdown(); | 683 arc_session_manager()->Shutdown(); |
| 634 } | 684 } |
| 635 | 685 |
| 636 INSTANTIATE_TEST_CASE_P( | 686 INSTANTIATE_TEST_CASE_P( |
| 637 ArcSessionManagerPolicyTest, | 687 , |
| 638 ArcSessionManagerPolicyTest, | 688 ArcSessionManagerPolicyTest, |
| 639 testing::Combine( | 689 testing::Combine( |
| 640 testing::Values(base::Value(), base::Value(false), base::Value(true)), | 690 testing::Values(base::Value(), base::Value(false), base::Value(true)), |
| 641 testing::Values(base::Value(), base::Value(false), base::Value(true)))); | 691 testing::Values(base::Value(), base::Value(false), base::Value(true)), |
| 692 testing::Bool())); |
| 642 | 693 |
| 643 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase { | 694 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase { |
| 644 public: | 695 public: |
| 645 ArcSessionManagerKioskTest() = default; | 696 ArcSessionManagerKioskTest() = default; |
| 646 | 697 |
| 647 void SetUp() override { | 698 void SetUp() override { |
| 648 ArcSessionManagerTestBase::SetUp(); | 699 ArcSessionManagerTestBase::SetUp(); |
| 649 const AccountId account_id( | 700 const AccountId account_id( |
| 650 AccountId::FromUserEmail(profile()->GetProfileUserName())); | 701 AccountId::FromUserEmail(profile()->GetProfileUserName())); |
| 651 GetFakeUserManager()->AddArcKioskAppUser(account_id); | 702 GetFakeUserManager()->AddArcKioskAppUser(account_id); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 667 // and not invoked then, including TearDown(). | 718 // and not invoked then, including TearDown(). |
| 668 bool terminated = false; | 719 bool terminated = false; |
| 669 arc_session_manager()->SetAttemptUserExitCallbackForTesting( | 720 arc_session_manager()->SetAttemptUserExitCallbackForTesting( |
| 670 base::Bind([](bool* terminated) { *terminated = true; }, &terminated)); | 721 base::Bind([](bool* terminated) { *terminated = true; }, &terminated)); |
| 671 | 722 |
| 672 arc_session_manager()->OnProvisioningFinished( | 723 arc_session_manager()->OnProvisioningFinished( |
| 673 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); | 724 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); |
| 674 EXPECT_TRUE(terminated); | 725 EXPECT_TRUE(terminated); |
| 675 } | 726 } |
| 676 | 727 |
| 677 class ArcSessionOobeOptInTest : public ArcSessionManagerTest { | 728 // This class takes two test parameters because the both itself and its child |
| 729 // need to be parameterized. Having redundant parameter here avoid the trouble |
| 730 // to deal with multiple inheritance from WithParamInterface instances. |
| 731 class ArcSessionOobeOptInTest |
| 732 : public AbstractArcSessionManagerTest, |
| 733 public ::testing::WithParamInterface<std::tuple<bool, bool>> { |
| 678 public: | 734 public: |
| 679 ArcSessionOobeOptInTest() = default; | 735 ArcSessionOobeOptInTest() = default; |
| 680 | 736 |
| 681 protected: | 737 protected: |
| 738 bool ShouldAlwaysStartArcInTest() override { return std::get<0>(GetParam()); } |
| 739 |
| 682 void CreateLoginDisplayHost() { | 740 void CreateLoginDisplayHost() { |
| 683 fake_login_display_host_ = base::MakeUnique<FakeLoginDisplayHost>(); | 741 fake_login_display_host_ = base::MakeUnique<FakeLoginDisplayHost>(); |
| 684 } | 742 } |
| 685 | 743 |
| 686 void CloseLoginDisplayHost() { fake_login_display_host_.reset(); } | 744 void CloseLoginDisplayHost() { fake_login_display_host_.reset(); } |
| 687 | 745 |
| 688 void AppendEnableArcOOBEOptInSwitch() { | 746 void AppendEnableArcOOBEOptInSwitch() { |
| 689 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 747 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 690 chromeos::switches::kEnableArcOOBEOptIn); | 748 chromeos::switches::kEnableArcOOBEOptIn); |
| 691 } | 749 } |
| 692 | 750 |
| 693 private: | 751 private: |
| 694 std::unique_ptr<FakeLoginDisplayHost> fake_login_display_host_; | 752 std::unique_ptr<FakeLoginDisplayHost> fake_login_display_host_; |
| 695 | 753 |
| 696 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInTest); | 754 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInTest); |
| 697 }; | 755 }; |
| 698 | 756 |
| 699 TEST_F(ArcSessionOobeOptInTest, OobeOptInActive) { | 757 INSTANTIATE_TEST_CASE_P( |
| 758 , |
| 759 ArcSessionOobeOptInTest, |
| 760 testing::Combine(::testing::Bool() /* always start arc */, |
| 761 ::testing::Values(false) /* dummy */)); |
| 762 |
| 763 TEST_P(ArcSessionOobeOptInTest, OobeOptInActive) { |
| 700 // OOBE OptIn is active in case of OOBE is started for new user and ARC OOBE | 764 // OOBE OptIn is active in case of OOBE is started for new user and ARC OOBE |
| 701 // is enabled by switch. | 765 // is enabled by switch. |
| 702 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 766 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 703 GetFakeUserManager()->set_current_user_new(true); | 767 GetFakeUserManager()->set_current_user_new(true); |
| 704 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 768 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 705 CreateLoginDisplayHost(); | 769 CreateLoginDisplayHost(); |
| 706 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 770 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 707 | 771 |
| 708 AppendEnableArcOOBEOptInSwitch(); | 772 AppendEnableArcOOBEOptInSwitch(); |
| 709 GetFakeUserManager()->set_current_user_new(false); | 773 GetFakeUserManager()->set_current_user_new(false); |
| 710 CloseLoginDisplayHost(); | 774 CloseLoginDisplayHost(); |
| 711 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 775 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 712 GetFakeUserManager()->set_current_user_new(true); | 776 GetFakeUserManager()->set_current_user_new(true); |
| 713 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 777 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 714 CreateLoginDisplayHost(); | 778 CreateLoginDisplayHost(); |
| 715 EXPECT_TRUE(ArcSessionManager::IsOobeOptInActive()); | 779 EXPECT_TRUE(ArcSessionManager::IsOobeOptInActive()); |
| 716 } | 780 } |
| 717 | 781 |
| 718 class ArcSessionOobeOptInNegotiatorTest | 782 class ArcSessionOobeOptInNegotiatorTest |
| 719 : public ArcSessionOobeOptInTest, | 783 : public ArcSessionOobeOptInTest, |
| 720 public chromeos::ArcTermsOfServiceScreenActor, | 784 public chromeos::ArcTermsOfServiceScreenActor { |
| 721 public testing::WithParamInterface<bool> { | |
| 722 public: | 785 public: |
| 723 ArcSessionOobeOptInNegotiatorTest() = default; | 786 ArcSessionOobeOptInNegotiatorTest() = default; |
| 724 | 787 |
| 725 void SetUp() override { | 788 void SetUp() override { |
| 726 ArcSessionOobeOptInTest::SetUp(); | 789 ArcSessionOobeOptInTest::SetUp(); |
| 727 | 790 |
| 728 AppendEnableArcOOBEOptInSwitch(); | 791 AppendEnableArcOOBEOptInSwitch(); |
| 729 | 792 |
| 730 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenActorForTesting( | 793 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenActorForTesting( |
| 731 this); | 794 this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 751 // Correctly stop service. | 814 // Correctly stop service. |
| 752 arc_session_manager()->Shutdown(); | 815 arc_session_manager()->Shutdown(); |
| 753 | 816 |
| 754 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenActorForTesting( | 817 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenActorForTesting( |
| 755 nullptr); | 818 nullptr); |
| 756 | 819 |
| 757 ArcSessionOobeOptInTest::TearDown(); | 820 ArcSessionOobeOptInTest::TearDown(); |
| 758 } | 821 } |
| 759 | 822 |
| 760 protected: | 823 protected: |
| 761 bool IsManagedUser() { return GetParam(); } | 824 bool ShouldAlwaysStartArcInTest() override { return std::get<0>(GetParam()); } |
| 825 bool IsManagedUser() { return std::get<1>(GetParam()); } |
| 762 | 826 |
| 763 void ReportResult(bool accepted) { | 827 void ReportResult(bool accepted) { |
| 764 for (auto& observer : observer_list_) { | 828 for (auto& observer : observer_list_) { |
| 765 if (accepted) | 829 if (accepted) |
| 766 observer.OnAccept(); | 830 observer.OnAccept(); |
| 767 else | 831 else |
| 768 observer.OnSkip(); | 832 observer.OnSkip(); |
| 769 } | 833 } |
| 770 base::RunLoop().RunUntilIdle(); | 834 base::RunLoop().RunUntilIdle(); |
| 771 } | 835 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 } | 873 } |
| 810 | 874 |
| 811 void Hide() override {} | 875 void Hide() override {} |
| 812 | 876 |
| 813 base::ObserverList<chromeos::ArcTermsOfServiceScreenActorObserver> | 877 base::ObserverList<chromeos::ArcTermsOfServiceScreenActorObserver> |
| 814 observer_list_; | 878 observer_list_; |
| 815 | 879 |
| 816 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInNegotiatorTest); | 880 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInNegotiatorTest); |
| 817 }; | 881 }; |
| 818 | 882 |
| 819 INSTANTIATE_TEST_CASE_P(ArcSessionOobeOptInNegotiatorTestImpl, | 883 // TODO(victorhsieh): Add test to cover when ARC always start |
| 820 ArcSessionOobeOptInNegotiatorTest, | 884 INSTANTIATE_TEST_CASE_P( |
| 821 ::testing::Values(true, false)); | 885 , |
| 886 ArcSessionOobeOptInNegotiatorTest, |
| 887 testing::Combine(::testing::Values(false) /* always start arc */, |
| 888 ::testing::Bool() /* managed user */)); |
| 822 | 889 |
| 823 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) { | 890 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) { |
| 824 actor()->Show(); | 891 actor()->Show(); |
| 825 MaybeWaitForDataRemoved(); | 892 MaybeWaitForDataRemoved(); |
| 826 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 893 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 827 arc_session_manager()->state()); | 894 arc_session_manager()->state()); |
| 828 ReportResult(true); | 895 ReportResult(true); |
| 829 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 896 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 830 EXPECT_TRUE(arc_session_manager()->IsArcPlayStoreEnabled()); | 897 EXPECT_TRUE(arc_session_manager()->IsArcPlayStoreEnabled()); |
| 831 } | 898 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 847 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 914 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 848 arc_session_manager()->state()); | 915 arc_session_manager()->state()); |
| 849 CloseLoginDisplayHost(); | 916 CloseLoginDisplayHost(); |
| 850 ReportActorDestroyed(); | 917 ReportActorDestroyed(); |
| 851 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); | 918 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); |
| 852 EXPECT_FALSE(!IsManagedUser() && | 919 EXPECT_FALSE(!IsManagedUser() && |
| 853 arc_session_manager()->IsArcPlayStoreEnabled()); | 920 arc_session_manager()->IsArcPlayStoreEnabled()); |
| 854 } | 921 } |
| 855 | 922 |
| 856 } // namespace arc | 923 } // namespace arc |
| OLD | NEW |