| 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 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 28 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 29 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 29 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 30 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 30 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 31 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 31 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 32 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 32 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 33 #include "chrome/browser/policy/profile_policy_connector.h" | 33 #include "chrome/browser/policy/profile_policy_connector.h" |
| 34 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 34 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 35 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 35 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 37 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 38 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 38 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 39 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 39 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| 40 #include "chrome/test/base/testing_profile.h" | 41 #include "chrome/test/base/testing_profile.h" |
| 41 #include "chromeos/chromeos_switches.h" | 42 #include "chromeos/chromeos_switches.h" |
| 42 #include "chromeos/dbus/dbus_thread_manager.h" | 43 #include "chromeos/dbus/dbus_thread_manager.h" |
| 43 #include "chromeos/dbus/fake_session_manager_client.h" | 44 #include "chromeos/dbus/fake_session_manager_client.h" |
| 44 #include "components/arc/arc_service_manager.h" | 45 #include "components/arc/arc_service_manager.h" |
| 45 #include "components/arc/arc_session_runner.h" | 46 #include "components/arc/arc_session_runner.h" |
| 46 #include "components/arc/arc_util.h" | 47 #include "components/arc/arc_util.h" |
| 47 #include "components/arc/test/fake_arc_session.h" | 48 #include "components/arc/test/fake_arc_session.h" |
| 48 #include "components/prefs/pref_service.h" | 49 #include "components/prefs/pref_service.h" |
| 49 #include "components/prefs/testing_pref_service.h" | 50 #include "components/prefs/testing_pref_service.h" |
| 50 #include "components/signin/core/account_id/account_id.h" | 51 #include "components/signin/core/account_id/account_id.h" |
| 51 #include "components/sync/model/fake_sync_change_processor.h" | 52 #include "components/sync/model/fake_sync_change_processor.h" |
| 52 #include "components/sync/model/sync_error_factory_mock.h" | 53 #include "components/sync/model/sync_error_factory_mock.h" |
| 53 #include "components/sync_preferences/testing_pref_service_syncable.h" | 54 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 54 #include "components/user_manager/user_manager.h" | 55 #include "components/user_manager/user_manager.h" |
| 55 #include "components/user_manager/user_names.h" | 56 #include "components/user_manager/user_names.h" |
| 56 #include "content/public/browser/browser_thread.h" | 57 #include "content/public/browser/browser_thread.h" |
| 57 #include "content/public/test/test_browser_thread_bundle.h" | 58 #include "content/public/test/test_browser_thread_bundle.h" |
| 58 #include "google_apis/gaia/gaia_constants.h" | 59 #include "google_apis/gaia/gaia_constants.h" |
| 59 #include "google_apis/gaia/gaia_urls.h" | 60 #include "google_apis/gaia/gaia_urls.h" |
| 60 #include "net/http/http_status_code.h" | 61 #include "net/http/http_status_code.h" |
| 61 #include "testing/gtest/include/gtest/gtest.h" | 62 #include "testing/gtest/include/gtest/gtest.h" |
| 62 | 63 |
| 63 namespace arc { | 64 namespace arc { |
| 64 | 65 |
| 65 namespace { | 66 namespace { |
| 66 | 67 |
| 68 enum ArcAlwaysStartOption : bool { |
| 69 ON = true, |
| 70 OFF = false, |
| 71 }; |
| 72 |
| 67 class FakeLoginDisplayHost : public chromeos::LoginDisplayHost { | 73 class FakeLoginDisplayHost : public chromeos::LoginDisplayHost { |
| 68 public: | 74 public: |
| 69 FakeLoginDisplayHost() { | 75 FakeLoginDisplayHost() { |
| 70 DCHECK(!chromeos::LoginDisplayHost::default_host_); | 76 DCHECK(!chromeos::LoginDisplayHost::default_host_); |
| 71 chromeos::LoginDisplayHost::default_host_ = this; | 77 chromeos::LoginDisplayHost::default_host_ = this; |
| 72 } | 78 } |
| 73 | 79 |
| 74 ~FakeLoginDisplayHost() override { | 80 ~FakeLoginDisplayHost() override { |
| 75 DCHECK_EQ(chromeos::LoginDisplayHost::default_host_, this); | 81 DCHECK_EQ(chromeos::LoginDisplayHost::default_host_, this); |
| 76 chromeos::LoginDisplayHost::default_host_ = nullptr; | 82 chromeos::LoginDisplayHost::default_host_ = nullptr; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 content::TestBrowserThreadBundle thread_bundle_; | 202 content::TestBrowserThreadBundle thread_bundle_; |
| 197 std::unique_ptr<TestingProfile> profile_; | 203 std::unique_ptr<TestingProfile> profile_; |
| 198 std::unique_ptr<ArcServiceManager> arc_service_manager_; | 204 std::unique_ptr<ArcServiceManager> arc_service_manager_; |
| 199 std::unique_ptr<ArcSessionManager> arc_session_manager_; | 205 std::unique_ptr<ArcSessionManager> arc_session_manager_; |
| 200 chromeos::ScopedUserManagerEnabler user_manager_enabler_; | 206 chromeos::ScopedUserManagerEnabler user_manager_enabler_; |
| 201 base::ScopedTempDir temp_dir_; | 207 base::ScopedTempDir temp_dir_; |
| 202 | 208 |
| 203 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTestBase); | 209 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTestBase); |
| 204 }; | 210 }; |
| 205 | 211 |
| 206 class ArcSessionManagerTest : public ArcSessionManagerTestBase { | 212 // Intermediate class so that the children can inject test parameter freely. |
| 213 class AbstractArcSessionManagerTest : public ArcSessionManagerTestBase { |
| 207 public: | 214 public: |
| 208 ArcSessionManagerTest() = default; | 215 AbstractArcSessionManagerTest() = default; |
| 209 | |
| 210 void SetUp() override { | 216 void SetUp() override { |
| 211 ArcSessionManagerTestBase::SetUp(); | 217 ArcSessionManagerTestBase::SetUp(); |
| 218 if (ShouldArcAlwaysStartInTest() == ArcAlwaysStartOption::ON) |
| 219 SetArcAlwaysStartForTesting(); |
| 212 | 220 |
| 213 const AccountId account_id(AccountId::FromUserEmailGaiaId( | 221 const AccountId account_id(AccountId::FromUserEmailGaiaId( |
| 214 profile()->GetProfileUserName(), "1234567890")); | 222 profile()->GetProfileUserName(), "1234567890")); |
| 215 GetFakeUserManager()->AddUser(account_id); | 223 GetFakeUserManager()->AddUser(account_id); |
| 216 GetFakeUserManager()->LoginUser(account_id); | 224 GetFakeUserManager()->LoginUser(account_id); |
| 217 | 225 |
| 218 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, | 226 ASSERT_EQ(ArcSessionManager::State::NOT_INITIALIZED, |
| 219 arc_session_manager()->state()); | 227 arc_session_manager()->state()); |
| 220 ASSERT_TRUE(arc_session_manager()->IsSessionStopped()); | 228 ASSERT_TRUE(arc_session_manager()->IsSessionStopped()); |
| 221 } | 229 } |
| 222 | 230 |
| 231 protected: |
| 232 virtual ArcAlwaysStartOption ShouldArcAlwaysStartInTest() = 0; |
| 233 |
| 234 private: |
| 235 DISALLOW_COPY_AND_ASSIGN(AbstractArcSessionManagerTest); |
| 236 }; |
| 237 |
| 238 class ArcSessionManagerTest |
| 239 : public AbstractArcSessionManagerTest, |
| 240 public testing::WithParamInterface<ArcAlwaysStartOption> { |
| 241 public: |
| 242 ArcSessionManagerTest() = default; |
| 243 |
| 244 protected: |
| 245 ArcAlwaysStartOption ShouldArcAlwaysStartInTest() override { |
| 246 return GetParam(); |
| 247 } |
| 248 |
| 223 private: | 249 private: |
| 224 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTest); | 250 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTest); |
| 225 }; | 251 }; |
| 226 | 252 |
| 227 TEST_F(ArcSessionManagerTest, BaseWorkflow) { | 253 INSTANTIATE_TEST_CASE_P(, |
| 254 ArcSessionManagerTest, |
| 255 testing::Values(ArcAlwaysStartOption::OFF, |
| 256 ArcAlwaysStartOption::ON)); |
| 257 |
| 258 TEST_P(ArcSessionManagerTest, BaseWorkflow) { |
| 259 if (ShouldArcAlwaysStart()) |
| 260 return; |
| 261 |
| 228 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 262 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 229 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); | 263 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); |
| 230 | 264 |
| 231 arc_session_manager()->SetProfile(profile()); | 265 arc_session_manager()->SetProfile(profile()); |
| 232 | 266 |
| 233 // By default ARC is not enabled. | 267 // By default ARC is not enabled. |
| 234 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); | 268 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); |
| 235 | 269 |
| 236 // Enables ARC. First time, ToS negotiation should start. | 270 // Enables ARC. First time, ToS negotiation should start. |
| 237 arc_session_manager()->RequestEnable(); | 271 arc_session_manager()->RequestEnable(); |
| 238 base::RunLoop().RunUntilIdle(); | 272 base::RunLoop().RunUntilIdle(); |
| 239 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 273 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 240 arc_session_manager()->state()); | 274 arc_session_manager()->state()); |
| 241 | 275 |
| 242 // TODO(hidehiko): Verify state transition from SHOWING_TERMS_OF_SERVICE -> | 276 // TODO(hidehiko): Verify state transition from SHOWING_TERMS_OF_SERVICE -> |
| 243 // CHECKING_ANDROID_MANAGEMENT, when we extract ArcSessionManager. | 277 // CHECKING_ANDROID_MANAGEMENT, when we extract ArcSessionManager. |
| 244 arc_session_manager()->StartArcForTesting(); | 278 arc_session_manager()->StartArcForTesting(); |
| 245 | 279 |
| 246 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 280 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 247 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); | 281 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); |
| 248 | 282 |
| 249 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 283 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 250 ASSERT_TRUE(arc_session_manager()->IsSessionRunning()); | 284 ASSERT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 251 | 285 |
| 252 arc_session_manager()->Shutdown(); | 286 arc_session_manager()->Shutdown(); |
| 253 } | 287 } |
| 254 | 288 |
| 255 TEST_F(ArcSessionManagerTest, CancelFetchingDisablesArc) { | 289 TEST_P(ArcSessionManagerTest, BaseWorkflowWithArcAlwaysStart) { |
| 290 if (!ShouldArcAlwaysStart()) |
| 291 return; |
| 292 |
| 293 // TODO(victorhsieh): Consider also tracking sign-in activity, which is |
| 294 // initiated from the Android side. |
| 295 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); |
| 296 |
| 297 arc_session_manager()->SetProfile(profile()); |
| 298 |
| 299 // By default ARC is not enabled. |
| 300 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); |
| 301 |
| 302 // When ARC is always started, ArcSessionManager should always be in ACTIVE |
| 303 // state. |
| 304 arc_session_manager()->RequestEnable(); |
| 305 base::RunLoop().RunUntilIdle(); |
| 306 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 307 |
| 308 arc_session_manager()->StartArcForTesting(); |
| 309 |
| 310 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); |
| 311 |
| 312 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 313 ASSERT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 314 |
| 315 arc_session_manager()->Shutdown(); |
| 316 } |
| 317 |
| 318 TEST_P(ArcSessionManagerTest, CancelFetchingDisablesArc) { |
| 319 // TODO(victorhsieh): Implement opt-in flow on Persistent ARC. |
| 320 if (ShouldArcAlwaysStart()) |
| 321 return; |
| 322 |
| 256 SetArcPlayStoreEnabledForProfile(profile(), true); | 323 SetArcPlayStoreEnabledForProfile(profile(), true); |
| 257 | 324 |
| 258 // Starts ARC. | 325 // Starts ARC. |
| 259 arc_session_manager()->SetProfile(profile()); | 326 arc_session_manager()->SetProfile(profile()); |
| 260 arc_session_manager()->RequestEnable(); | 327 arc_session_manager()->RequestEnable(); |
| 261 base::RunLoop().RunUntilIdle(); | 328 base::RunLoop().RunUntilIdle(); |
| 262 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 329 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 263 arc_session_manager()->state()); | 330 arc_session_manager()->state()); |
| 264 | 331 |
| 265 // Emulate to cancel the ToS UI (e.g. closing the window). | 332 // Emulate to cancel the ToS UI (e.g. closing the window). |
| 266 arc_session_manager()->CancelAuthCode(); | 333 arc_session_manager()->CancelAuthCode(); |
| 267 | 334 |
| 268 // Google Play Store enabled preference should be set to false, too. | 335 // Google Play Store enabled preference should be set to false, too. |
| 269 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); | 336 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); |
| 270 | 337 |
| 271 // Emulate the preference handling. | 338 // Emulate the preference handling. |
| 272 arc_session_manager()->RequestDisable(); | 339 arc_session_manager()->RequestDisable(); |
| 273 | 340 |
| 274 // Wait until data is removed. | 341 // Wait until data is removed. |
| 275 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); | 342 ASSERT_TRUE(WaitForDataRemoved(ArcSessionManager::State::STOPPED)); |
| 276 | 343 |
| 277 // Correctly stop service. | 344 // Correctly stop service. |
| 278 arc_session_manager()->Shutdown(); | 345 arc_session_manager()->Shutdown(); |
| 279 } | 346 } |
| 280 | 347 |
| 281 TEST_F(ArcSessionManagerTest, CloseUIKeepsArcEnabled) { | 348 TEST_P(ArcSessionManagerTest, CloseUIKeepsArcEnabled) { |
| 349 // TODO(victorhsieh): Implement opt-in flow. |
| 350 if (ShouldArcAlwaysStart()) |
| 351 return; |
| 352 |
| 282 // Starts ARC. | 353 // Starts ARC. |
| 283 SetArcPlayStoreEnabledForProfile(profile(), true); | 354 SetArcPlayStoreEnabledForProfile(profile(), true); |
| 284 arc_session_manager()->SetProfile(profile()); | 355 arc_session_manager()->SetProfile(profile()); |
| 285 arc_session_manager()->RequestEnable(); | 356 arc_session_manager()->RequestEnable(); |
| 286 base::RunLoop().RunUntilIdle(); | 357 base::RunLoop().RunUntilIdle(); |
| 287 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 358 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 288 arc_session_manager()->state()); | 359 arc_session_manager()->state()); |
| 289 arc_session_manager()->StartArcForTesting(); | 360 arc_session_manager()->StartArcForTesting(); |
| 290 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 361 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 291 | 362 |
| 292 // When ARC is properly started, closing UI should be no-op. | 363 // When ARC is properly started, closing UI should be no-op. |
| 293 arc_session_manager()->CancelAuthCode(); | 364 arc_session_manager()->CancelAuthCode(); |
| 294 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 365 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 295 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile())); | 366 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile())); |
| 296 | 367 |
| 297 // Correctly stop service. | 368 // Correctly stop service. |
| 298 arc_session_manager()->Shutdown(); | 369 arc_session_manager()->Shutdown(); |
| 299 } | 370 } |
| 300 | 371 |
| 301 TEST_F(ArcSessionManagerTest, Provisioning_Success) { | 372 TEST_P(ArcSessionManagerTest, Provisioning_Success) { |
| 302 PrefService* const prefs = profile()->GetPrefs(); | 373 PrefService* const prefs = profile()->GetPrefs(); |
| 303 | 374 |
| 304 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 375 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 305 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); | 376 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); |
| 306 EXPECT_FALSE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting()); | 377 EXPECT_FALSE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting()); |
| 307 | 378 |
| 308 ASSERT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 379 ASSERT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 309 | 380 |
| 310 arc_session_manager()->SetProfile(profile()); | 381 arc_session_manager()->SetProfile(profile()); |
| 311 arc_session_manager()->RequestEnable(); | 382 arc_session_manager()->RequestEnable(); |
| 312 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 383 if (ShouldArcAlwaysStart()) { |
| 313 arc_session_manager()->state()); | 384 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 385 } else { |
| 386 ASSERT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 387 arc_session_manager()->state()); |
| 388 } |
| 314 | 389 |
| 315 // Emulate to accept the terms of service. | 390 // Emulate to accept the terms of service. |
| 316 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | 391 prefs->SetBoolean(prefs::kArcTermsAccepted, true); |
| 317 arc_session_manager()->StartArcForTesting(); | 392 if (!ShouldArcAlwaysStart()) |
| 393 arc_session_manager()->StartArcForTesting(); |
| 318 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 394 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 319 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); | 395 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 320 | 396 |
| 321 // Here, provisining is not yet completed, so kArcSignedIn should be false. | 397 // Here, provisining is not yet completed, so kArcSignedIn should be false. |
| 322 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 398 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 323 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); | 399 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); |
| 324 EXPECT_FALSE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting()); | 400 EXPECT_FALSE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting()); |
| 325 | 401 |
| 326 // Emulate successful provisioning. | 402 // Emulate successful provisioning. |
| 327 arc_session_manager()->OnProvisioningFinished(ProvisioningResult::SUCCESS); | 403 arc_session_manager()->OnProvisioningFinished(ProvisioningResult::SUCCESS); |
| 328 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); | 404 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 329 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 405 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 330 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); | 406 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 331 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 407 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 332 EXPECT_TRUE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting()); | 408 EXPECT_TRUE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting()); |
| 333 } | 409 } |
| 334 | 410 |
| 335 TEST_F(ArcSessionManagerTest, Provisioning_Restart) { | 411 TEST_P(ArcSessionManagerTest, Provisioning_Restart) { |
| 336 // Set up the situation that provisioning is successfully done in the | 412 // Set up the situation that provisioning is successfully done in the |
| 337 // previous session. | 413 // previous session. |
| 338 PrefService* const prefs = profile()->GetPrefs(); | 414 PrefService* const prefs = profile()->GetPrefs(); |
| 339 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | 415 prefs->SetBoolean(prefs::kArcTermsAccepted, true); |
| 340 prefs->SetBoolean(prefs::kArcSignedIn, true); | 416 prefs->SetBoolean(prefs::kArcSignedIn, true); |
| 341 | 417 |
| 342 arc_session_manager()->SetProfile(profile()); | 418 arc_session_manager()->SetProfile(profile()); |
| 343 arc_session_manager()->RequestEnable(); | 419 arc_session_manager()->RequestEnable(); |
| 344 | 420 |
| 345 // Second start, no fetching code is expected. | 421 // Second start, no fetching code is expected. |
| 346 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 422 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 347 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); | 423 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 348 | 424 |
| 349 // Report failure. | 425 // Report failure. |
| 350 arc_session_manager()->OnProvisioningFinished( | 426 arc_session_manager()->OnProvisioningFinished( |
| 351 ProvisioningResult::GMS_NETWORK_ERROR); | 427 ProvisioningResult::GMS_NETWORK_ERROR); |
| 352 // On error, UI to send feedback is showing. In that case, | 428 // On error, UI to send feedback is showing. In that case, |
| 353 // the ARC is still necessary to run on background for gathering the logs. | 429 // the ARC is still necessary to run on background for gathering the logs. |
| 354 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); | 430 EXPECT_TRUE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 355 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 431 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 356 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); | 432 EXPECT_TRUE(arc_session_manager()->IsSessionRunning()); |
| 357 | 433 |
| 358 // Correctly stop service. | 434 // Correctly stop service. |
| 359 arc_session_manager()->Shutdown(); | 435 arc_session_manager()->Shutdown(); |
| 360 } | 436 } |
| 361 | 437 |
| 362 TEST_F(ArcSessionManagerTest, RemoveDataDir) { | 438 TEST_P(ArcSessionManagerTest, RemoveDataDir) { |
| 439 // TODO(victorhsieh): Implement data removal on Persistent ARC. |
| 440 if (ShouldArcAlwaysStart()) |
| 441 return; |
| 442 |
| 363 // Emulate the situation where the initial Google Play Store enabled | 443 // Emulate the situation where the initial Google Play Store enabled |
| 364 // preference is false for managed user, i.e., data dir is being removed at | 444 // preference is false for managed user, i.e., data dir is being removed at |
| 365 // beginning. | 445 // beginning. |
| 366 arc_session_manager()->SetProfile(profile()); | 446 arc_session_manager()->SetProfile(profile()); |
| 367 arc_session_manager()->RemoveArcData(); | 447 arc_session_manager()->RemoveArcData(); |
| 448 |
| 368 EXPECT_TRUE( | 449 EXPECT_TRUE( |
| 369 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 450 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 370 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, | 451 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, |
| 371 arc_session_manager()->state()); | 452 arc_session_manager()->state()); |
| 372 | 453 |
| 373 // Enable ARC. Data is removed asyncronously. At this moment session manager | 454 // Enable ARC. Data is removed asyncronously. At this moment session manager |
| 374 // should be in REMOVING_DATA_DIR state. | 455 // should be in REMOVING_DATA_DIR state. |
| 375 arc_session_manager()->RequestEnable(); | 456 arc_session_manager()->RequestEnable(); |
| 376 EXPECT_TRUE( | 457 EXPECT_TRUE( |
| 377 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 458 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 391 ASSERT_TRUE( | 472 ASSERT_TRUE( |
| 392 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 473 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 393 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 474 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 394 arc_session_manager()->Shutdown(); | 475 arc_session_manager()->Shutdown(); |
| 395 base::RunLoop().RunUntilIdle(); | 476 base::RunLoop().RunUntilIdle(); |
| 396 // Request should persist. | 477 // Request should persist. |
| 397 ASSERT_TRUE( | 478 ASSERT_TRUE( |
| 398 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 479 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 399 } | 480 } |
| 400 | 481 |
| 401 TEST_F(ArcSessionManagerTest, RemoveDataDir_Restart) { | 482 TEST_P(ArcSessionManagerTest, RemoveDataDir_Restart) { |
| 483 // TODO(victorhsieh): Implement data removal on Persistent ARC. |
| 484 if (ShouldArcAlwaysStart()) |
| 485 return; |
| 486 |
| 402 // Emulate second sign-in. Data should be removed first and ARC started after. | 487 // Emulate second sign-in. Data should be removed first and ARC started after. |
| 403 PrefService* const prefs = profile()->GetPrefs(); | 488 PrefService* const prefs = profile()->GetPrefs(); |
| 404 prefs->SetBoolean(prefs::kArcDataRemoveRequested, true); | 489 prefs->SetBoolean(prefs::kArcDataRemoveRequested, true); |
| 405 arc_session_manager()->SetProfile(profile()); | 490 arc_session_manager()->SetProfile(profile()); |
| 406 arc_session_manager()->RequestEnable(); | 491 arc_session_manager()->RequestEnable(); |
| 407 EXPECT_TRUE( | 492 EXPECT_TRUE( |
| 408 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 493 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 409 ASSERT_TRUE( | 494 ASSERT_TRUE( |
| 410 WaitForDataRemoved(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE)); | 495 WaitForDataRemoved(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE)); |
| 411 EXPECT_FALSE( | 496 EXPECT_FALSE( |
| 412 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 497 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 413 | 498 |
| 414 arc_session_manager()->Shutdown(); | 499 arc_session_manager()->Shutdown(); |
| 415 } | 500 } |
| 416 | 501 |
| 417 TEST_F(ArcSessionManagerTest, IgnoreSecondErrorReporting) { | 502 TEST_P(ArcSessionManagerTest, IgnoreSecondErrorReporting) { |
| 418 arc_session_manager()->SetProfile(profile()); | 503 arc_session_manager()->SetProfile(profile()); |
| 419 arc_session_manager()->RequestEnable(); | 504 arc_session_manager()->RequestEnable(); |
| 420 arc_session_manager()->StartArcForTesting(); | 505 arc_session_manager()->StartArcForTesting(); |
| 421 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 506 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 422 | 507 |
| 423 // Report some failure that does not stop the bridge. | 508 // Report some failure that does not stop the bridge. |
| 424 arc_session_manager()->OnProvisioningFinished( | 509 arc_session_manager()->OnProvisioningFinished( |
| 425 ProvisioningResult::GMS_SIGN_IN_FAILED); | 510 ProvisioningResult::GMS_SIGN_IN_FAILED); |
| 426 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 511 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 427 | 512 |
| 428 // Try to send another error that stops the bridge if sent first. It should | 513 // Try to send another error that stops the bridge if sent first. It should |
| 429 // be ignored. | 514 // be ignored. |
| 430 arc_session_manager()->OnProvisioningFinished( | 515 arc_session_manager()->OnProvisioningFinished( |
| 431 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); | 516 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); |
| 432 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 517 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 433 | 518 |
| 434 arc_session_manager()->Shutdown(); | 519 arc_session_manager()->Shutdown(); |
| 435 } | 520 } |
| 436 | 521 |
| 437 class ArcSessionManagerPolicyTest | 522 class ArcSessionManagerPolicyTest |
| 438 : public ArcSessionManagerTest, | 523 : public AbstractArcSessionManagerTest, |
| 439 public testing::WithParamInterface<std::tuple<base::Value, base::Value>> { | 524 public testing::WithParamInterface< |
| 525 std::tuple<base::Value, base::Value, ArcAlwaysStartOption>> { |
| 440 public: | 526 public: |
| 441 const base::Value& backup_restore_pref_value() const { | 527 const base::Value& backup_restore_pref_value() const { |
| 442 return std::get<0>(GetParam()); | 528 return std::get<0>(GetParam()); |
| 443 } | 529 } |
| 444 | 530 |
| 445 const base::Value& location_service_pref_value() const { | 531 const base::Value& location_service_pref_value() const { |
| 446 return std::get<1>(GetParam()); | 532 return std::get<1>(GetParam()); |
| 447 } | 533 } |
| 534 |
| 535 protected: |
| 536 ArcAlwaysStartOption ShouldArcAlwaysStartInTest() override { |
| 537 return std::get<2>(GetParam()); |
| 538 } |
| 448 }; | 539 }; |
| 449 | 540 |
| 450 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) { | 541 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) { |
| 542 // TODO(victorhsieh): Implement opt-in flow. |
| 543 if (ShouldArcAlwaysStart()) |
| 544 return; |
| 545 |
| 451 sync_preferences::TestingPrefServiceSyncable* const prefs = | 546 sync_preferences::TestingPrefServiceSyncable* const prefs = |
| 452 profile()->GetTestingPrefService(); | 547 profile()->GetTestingPrefService(); |
| 453 | 548 |
| 454 // Backup-restore and location-service prefs are off by default. | 549 // Backup-restore and location-service prefs are off by default. |
| 455 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 550 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 456 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted)); | 551 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted)); |
| 457 | 552 |
| 458 // Set ARC to be managed. | 553 // Set ARC to be managed. |
| 459 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true)); | 554 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true)); |
| 460 | 555 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 598 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 504 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled)); | 599 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 505 | 600 |
| 506 // Stop ARC and shutdown the service. | 601 // Stop ARC and shutdown the service. |
| 507 prefs->RemoveManagedPref(prefs::kArcEnabled); | 602 prefs->RemoveManagedPref(prefs::kArcEnabled); |
| 508 WaitForDataRemoved(ArcSessionManager::State::STOPPED); | 603 WaitForDataRemoved(ArcSessionManager::State::STOPPED); |
| 509 arc_session_manager()->Shutdown(); | 604 arc_session_manager()->Shutdown(); |
| 510 } | 605 } |
| 511 | 606 |
| 512 INSTANTIATE_TEST_CASE_P( | 607 INSTANTIATE_TEST_CASE_P( |
| 513 ArcSessionManagerPolicyTest, | 608 , |
| 514 ArcSessionManagerPolicyTest, | 609 ArcSessionManagerPolicyTest, |
| 515 testing::Combine( | 610 testing::Combine( |
| 516 testing::Values(base::Value(), base::Value(false), base::Value(true)), | 611 testing::Values(base::Value(), base::Value(false), base::Value(true)), |
| 517 testing::Values(base::Value(), base::Value(false), base::Value(true)))); | 612 testing::Values(base::Value(), base::Value(false), base::Value(true)), |
| 613 testing::Values(ArcAlwaysStartOption::OFF, ArcAlwaysStartOption::ON))); |
| 518 | 614 |
| 519 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase { | 615 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase { |
| 520 public: | 616 public: |
| 521 ArcSessionManagerKioskTest() = default; | 617 ArcSessionManagerKioskTest() = default; |
| 522 | 618 |
| 523 void SetUp() override { | 619 void SetUp() override { |
| 524 ArcSessionManagerTestBase::SetUp(); | 620 ArcSessionManagerTestBase::SetUp(); |
| 525 const AccountId account_id( | 621 const AccountId account_id( |
| 526 AccountId::FromUserEmail(profile()->GetProfileUserName())); | 622 AccountId::FromUserEmail(profile()->GetProfileUserName())); |
| 527 GetFakeUserManager()->AddArcKioskAppUser(account_id); | 623 GetFakeUserManager()->AddArcKioskAppUser(account_id); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 543 // and not invoked then, including TearDown(). | 639 // and not invoked then, including TearDown(). |
| 544 bool terminated = false; | 640 bool terminated = false; |
| 545 arc_session_manager()->SetAttemptUserExitCallbackForTesting( | 641 arc_session_manager()->SetAttemptUserExitCallbackForTesting( |
| 546 base::Bind([](bool* terminated) { *terminated = true; }, &terminated)); | 642 base::Bind([](bool* terminated) { *terminated = true; }, &terminated)); |
| 547 | 643 |
| 548 arc_session_manager()->OnProvisioningFinished( | 644 arc_session_manager()->OnProvisioningFinished( |
| 549 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); | 645 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); |
| 550 EXPECT_TRUE(terminated); | 646 EXPECT_TRUE(terminated); |
| 551 } | 647 } |
| 552 | 648 |
| 553 class ArcSessionOobeOptInTest : public ArcSessionManagerTest { | 649 // This class takes two test parameters because both itself and its child need |
| 650 // to be parameterized. Having redundant parameter here avoid the trouble to |
| 651 // deal with multiple inheritance from WithParamInterface instances. |
| 652 class ArcSessionOobeOptInTest : public AbstractArcSessionManagerTest, |
| 653 public testing::WithParamInterface< |
| 654 std::tuple<ArcAlwaysStartOption, bool>> { |
| 554 public: | 655 public: |
| 555 ArcSessionOobeOptInTest() = default; | 656 ArcSessionOobeOptInTest() = default; |
| 556 | 657 |
| 557 protected: | 658 protected: |
| 659 ArcAlwaysStartOption ShouldArcAlwaysStartInTest() override { |
| 660 return std::get<0>(GetParam()); |
| 661 } |
| 662 |
| 558 void CreateLoginDisplayHost() { | 663 void CreateLoginDisplayHost() { |
| 559 fake_login_display_host_ = base::MakeUnique<FakeLoginDisplayHost>(); | 664 fake_login_display_host_ = base::MakeUnique<FakeLoginDisplayHost>(); |
| 560 } | 665 } |
| 561 | 666 |
| 562 void CloseLoginDisplayHost() { fake_login_display_host_.reset(); } | 667 void CloseLoginDisplayHost() { fake_login_display_host_.reset(); } |
| 563 | 668 |
| 564 void AppendEnableArcOOBEOptInSwitch() { | 669 void AppendEnableArcOOBEOptInSwitch() { |
| 565 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 670 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 566 chromeos::switches::kEnableArcOOBEOptIn); | 671 chromeos::switches::kEnableArcOOBEOptIn); |
| 567 } | 672 } |
| 568 | 673 |
| 569 private: | 674 private: |
| 570 std::unique_ptr<FakeLoginDisplayHost> fake_login_display_host_; | 675 std::unique_ptr<FakeLoginDisplayHost> fake_login_display_host_; |
| 571 | 676 |
| 572 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInTest); | 677 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInTest); |
| 573 }; | 678 }; |
| 574 | 679 |
| 575 TEST_F(ArcSessionOobeOptInTest, OobeOptInActive) { | 680 INSTANTIATE_TEST_CASE_P( |
| 681 , |
| 682 ArcSessionOobeOptInTest, |
| 683 testing::Combine(testing::Values(ArcAlwaysStartOption::OFF, |
| 684 ArcAlwaysStartOption::ON), |
| 685 testing::Values(false) /* dummy */)); |
| 686 |
| 687 TEST_P(ArcSessionOobeOptInTest, OobeOptInActive) { |
| 576 // OOBE OptIn is active in case of OOBE is started for new user and ARC OOBE | 688 // OOBE OptIn is active in case of OOBE is started for new user and ARC OOBE |
| 577 // is enabled by switch. | 689 // is enabled by switch. |
| 578 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 690 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 579 GetFakeUserManager()->set_current_user_new(true); | 691 GetFakeUserManager()->set_current_user_new(true); |
| 580 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 692 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 581 CreateLoginDisplayHost(); | 693 CreateLoginDisplayHost(); |
| 582 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 694 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 583 | 695 |
| 584 AppendEnableArcOOBEOptInSwitch(); | 696 AppendEnableArcOOBEOptInSwitch(); |
| 585 GetFakeUserManager()->set_current_user_new(false); | 697 GetFakeUserManager()->set_current_user_new(false); |
| 586 CloseLoginDisplayHost(); | 698 CloseLoginDisplayHost(); |
| 587 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 699 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 588 GetFakeUserManager()->set_current_user_new(true); | 700 GetFakeUserManager()->set_current_user_new(true); |
| 589 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); | 701 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); |
| 590 CreateLoginDisplayHost(); | 702 CreateLoginDisplayHost(); |
| 591 EXPECT_TRUE(ArcSessionManager::IsOobeOptInActive()); | 703 EXPECT_TRUE(ArcSessionManager::IsOobeOptInActive()); |
| 592 } | 704 } |
| 593 | 705 |
| 594 class ArcSessionOobeOptInNegotiatorTest | 706 class ArcSessionOobeOptInNegotiatorTest |
| 595 : public ArcSessionOobeOptInTest, | 707 : public ArcSessionOobeOptInTest, |
| 596 public chromeos::ArcTermsOfServiceScreenView, | 708 public chromeos::ArcTermsOfServiceScreenView { |
| 597 public testing::WithParamInterface<bool> { | |
| 598 public: | 709 public: |
| 599 ArcSessionOobeOptInNegotiatorTest() = default; | 710 ArcSessionOobeOptInNegotiatorTest() = default; |
| 600 | 711 |
| 601 void SetUp() override { | 712 void SetUp() override { |
| 602 ArcSessionOobeOptInTest::SetUp(); | 713 ArcSessionOobeOptInTest::SetUp(); |
| 603 | 714 |
| 604 AppendEnableArcOOBEOptInSwitch(); | 715 AppendEnableArcOOBEOptInSwitch(); |
| 605 | 716 |
| 606 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenViewForTesting( | 717 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenViewForTesting( |
| 607 this); | 718 this); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 629 // Correctly stop service. | 740 // Correctly stop service. |
| 630 arc_session_manager()->Shutdown(); | 741 arc_session_manager()->Shutdown(); |
| 631 | 742 |
| 632 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenViewForTesting( | 743 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenViewForTesting( |
| 633 nullptr); | 744 nullptr); |
| 634 | 745 |
| 635 ArcSessionOobeOptInTest::TearDown(); | 746 ArcSessionOobeOptInTest::TearDown(); |
| 636 } | 747 } |
| 637 | 748 |
| 638 protected: | 749 protected: |
| 639 bool IsManagedUser() { return GetParam(); } | 750 ArcAlwaysStartOption ShouldArcAlwaysStartInTest() override { |
| 751 return std::get<0>(GetParam()); |
| 752 } |
| 753 |
| 754 bool IsManagedUser() { return std::get<1>(GetParam()); } |
| 640 | 755 |
| 641 void ReportResult(bool accepted) { | 756 void ReportResult(bool accepted) { |
| 642 for (auto& observer : observer_list_) { | 757 for (auto& observer : observer_list_) { |
| 643 if (accepted) | 758 if (accepted) |
| 644 observer.OnAccept(); | 759 observer.OnAccept(); |
| 645 else | 760 else |
| 646 observer.OnSkip(); | 761 observer.OnSkip(); |
| 647 } | 762 } |
| 648 base::RunLoop().RunUntilIdle(); | 763 base::RunLoop().RunUntilIdle(); |
| 649 } | 764 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 676 } | 791 } |
| 677 | 792 |
| 678 void Hide() override {} | 793 void Hide() override {} |
| 679 | 794 |
| 680 base::ObserverList<chromeos::ArcTermsOfServiceScreenViewObserver> | 795 base::ObserverList<chromeos::ArcTermsOfServiceScreenViewObserver> |
| 681 observer_list_; | 796 observer_list_; |
| 682 | 797 |
| 683 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInNegotiatorTest); | 798 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInNegotiatorTest); |
| 684 }; | 799 }; |
| 685 | 800 |
| 686 INSTANTIATE_TEST_CASE_P(ArcSessionOobeOptInNegotiatorTestImpl, | 801 // TODO(victorhsieh): Add test to cover when ARC always start |
| 687 ArcSessionOobeOptInNegotiatorTest, | 802 INSTANTIATE_TEST_CASE_P( |
| 688 ::testing::Values(true, false)); | 803 , |
| 804 ArcSessionOobeOptInNegotiatorTest, |
| 805 testing::Combine(testing::Values(ArcAlwaysStartOption::OFF), |
| 806 testing::Bool() /* managed user */)); |
| 689 | 807 |
| 690 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) { | 808 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) { |
| 691 view()->Show(); | 809 view()->Show(); |
| 692 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 810 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 693 arc_session_manager()->state()); | 811 arc_session_manager()->state()); |
| 694 ReportResult(true); | 812 ReportResult(true); |
| 695 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 813 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 696 } | 814 } |
| 697 | 815 |
| 698 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) { | 816 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) { |
| 699 view()->Show(); | 817 view()->Show(); |
| 700 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 818 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 701 arc_session_manager()->state()); | 819 arc_session_manager()->state()); |
| 702 ReportResult(false); | 820 ReportResult(false); |
| 703 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); | 821 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); |
| 704 } | 822 } |
| 705 | 823 |
| 706 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsViewDestroyed) { | 824 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsViewDestroyed) { |
| 707 view()->Show(); | 825 view()->Show(); |
| 708 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 826 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 709 arc_session_manager()->state()); | 827 arc_session_manager()->state()); |
| 710 CloseLoginDisplayHost(); | 828 CloseLoginDisplayHost(); |
| 711 ReportViewDestroyed(); | 829 ReportViewDestroyed(); |
| 712 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); | 830 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); |
| 713 } | 831 } |
| 714 | 832 |
| 715 } // namespace arc | 833 } // namespace arc |
| OLD | NEW |