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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 // Correctly stop service. | 359 // Correctly stop service. |
360 arc_session_manager()->Shutdown(); | 360 arc_session_manager()->Shutdown(); |
361 } | 361 } |
362 | 362 |
363 TEST_F(ArcSessionManagerTest, RemoveDataDir) { | 363 TEST_F(ArcSessionManagerTest, RemoveDataDir) { |
364 // Emulate the situation where the initial Google Play Store enabled | 364 // Emulate the situation where the initial Google Play Store enabled |
365 // preference is false for managed user, i.e., data dir is being removed at | 365 // preference is false for managed user, i.e., data dir is being removed at |
366 // beginning. | 366 // beginning. |
367 arc_session_manager()->SetProfile(profile()); | 367 arc_session_manager()->SetProfile(profile()); |
368 arc_session_manager()->RemoveArcData(); | 368 arc_session_manager()->RequestArcDataRemoval(); |
369 EXPECT_TRUE( | 369 EXPECT_TRUE( |
370 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 370 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
371 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, | 371 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, |
372 arc_session_manager()->state()); | 372 arc_session_manager()->state()); |
373 | 373 |
374 // Enable ARC. Data is removed asyncronously. At this moment session manager | 374 // Enable ARC. Data is removed asyncronously. At this moment session manager |
375 // should be in REMOVING_DATA_DIR state. | 375 // should be in REMOVING_DATA_DIR state. |
376 arc_session_manager()->RequestEnable(); | 376 arc_session_manager()->RequestEnable(); |
377 EXPECT_TRUE( | 377 EXPECT_TRUE( |
378 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 378 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
379 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, | 379 EXPECT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, |
380 arc_session_manager()->state()); | 380 arc_session_manager()->state()); |
381 // Wait until data is removed. | 381 // Wait until data is removed. |
382 base::RunLoop().RunUntilIdle(); | 382 base::RunLoop().RunUntilIdle(); |
383 EXPECT_FALSE( | 383 EXPECT_FALSE( |
384 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 384 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
385 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, | 385 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, |
386 arc_session_manager()->state()); | 386 arc_session_manager()->state()); |
387 arc_session_manager()->StartArcForTesting(); | 387 arc_session_manager()->StartArcForTesting(); |
388 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 388 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
389 | 389 |
390 // Request to remove data and stop session manager. | 390 // Request to remove data and stop session manager. |
391 arc_session_manager()->RemoveArcData(); | 391 arc_session_manager()->RequestArcDataRemoval(); |
392 ASSERT_TRUE( | 392 ASSERT_TRUE( |
393 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 393 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
394 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 394 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
395 arc_session_manager()->Shutdown(); | 395 arc_session_manager()->Shutdown(); |
396 base::RunLoop().RunUntilIdle(); | 396 base::RunLoop().RunUntilIdle(); |
397 // Request should persist. | 397 // Request should persist. |
398 ASSERT_TRUE( | 398 ASSERT_TRUE( |
399 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | 399 profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
400 } | 400 } |
401 | 401 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should | 758 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should |
759 // be kept as is. | 759 // be kept as is. |
760 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, | 760 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, |
761 arc_session_manager()->state()); | 761 arc_session_manager()->state()); |
762 // Managed user's preference should not be overwritten. | 762 // Managed user's preference should not be overwritten. |
763 if (!IsManagedUser()) | 763 if (!IsManagedUser()) |
764 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); | 764 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); |
765 } | 765 } |
766 | 766 |
767 } // namespace arc | 767 } // namespace arc |
OLD | NEW |