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

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

Issue 2702893002: Revert of Skip ARC initial screen when everything is set up by policy (Closed)
Patch Set: Created 3 years, 10 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
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 #include <tuple>
8 #include <vector> 7 #include <vector>
9 8
10 #include "base/bind.h" 9 #include "base/bind.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
14 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
15 #include "base/logging.h"
16 #include "base/macros.h" 14 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
18 #include "base/observer_list.h" 16 #include "base/observer_list.h"
19 #include "base/run_loop.h" 17 #include "base/run_loop.h"
20 #include "base/values.h"
21 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" 18 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
22 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 19 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
23 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator .h" 20 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator .h"
24 #include "chrome/browser/chromeos/arc/test/arc_data_removed_waiter.h" 21 #include "chrome/browser/chromeos/arc/test/arc_data_removed_waiter.h"
25 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto r.h" 22 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto r.h"
26 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto r_observer.h" 23 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto r_observer.h"
27 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 24 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
28 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 25 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
29 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 26 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
30 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 27 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
31 #include "chrome/browser/chromeos/profiles/profile_helper.h" 28 #include "chrome/browser/chromeos/profiles/profile_helper.h"
32 #include "chrome/browser/policy/profile_policy_connector.h" 29 #include "chrome/browser/policy/profile_policy_connector.h"
33 #include "chrome/browser/policy/profile_policy_connector_factory.h" 30 #include "chrome/browser/policy/profile_policy_connector_factory.h"
34 #include "chrome/browser/prefs/pref_service_syncable_util.h" 31 #include "chrome/browser/prefs/pref_service_syncable_util.h"
35 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 33 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
37 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 34 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
38 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
39 #include "chrome/test/base/testing_profile.h" 36 #include "chrome/test/base/testing_profile.h"
40 #include "chromeos/chromeos_switches.h" 37 #include "chromeos/chromeos_switches.h"
41 #include "chromeos/dbus/dbus_thread_manager.h" 38 #include "chromeos/dbus/dbus_thread_manager.h"
42 #include "chromeos/dbus/fake_session_manager_client.h" 39 #include "chromeos/dbus/fake_session_manager_client.h"
43 #include "components/arc/arc_service_manager.h" 40 #include "components/arc/arc_service_manager.h"
44 #include "components/arc/arc_session_runner.h" 41 #include "components/arc/arc_session_runner.h"
45 #include "components/arc/arc_util.h" 42 #include "components/arc/arc_util.h"
46 #include "components/arc/test/fake_arc_session.h" 43 #include "components/arc/test/fake_arc_session.h"
47 #include "components/prefs/pref_service.h" 44 #include "components/prefs/pref_service.h"
48 #include "components/prefs/testing_pref_service.h"
49 #include "components/signin/core/account_id/account_id.h" 45 #include "components/signin/core/account_id/account_id.h"
50 #include "components/sync/model/fake_sync_change_processor.h" 46 #include "components/sync/model/fake_sync_change_processor.h"
51 #include "components/sync/model/sync_error_factory_mock.h" 47 #include "components/sync/model/sync_error_factory_mock.h"
52 #include "components/sync_preferences/testing_pref_service_syncable.h" 48 #include "components/sync_preferences/testing_pref_service_syncable.h"
53 #include "components/user_manager/user_manager.h" 49 #include "components/user_manager/user_manager.h"
54 #include "components/user_manager/user_names.h" 50 #include "components/user_manager/user_names.h"
55 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
56 #include "content/public/test/test_browser_thread_bundle.h" 52 #include "content/public/test/test_browser_thread_bundle.h"
57 #include "google_apis/gaia/gaia_constants.h" 53 #include "google_apis/gaia/gaia_constants.h"
58 #include "google_apis/gaia/gaia_urls.h" 54 #include "google_apis/gaia/gaia_urls.h"
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 560
565 // Try to send another error that stops the bridge if sent first. It should 561 // Try to send another error that stops the bridge if sent first. It should
566 // be ignored. 562 // be ignored.
567 arc_session_manager()->OnProvisioningFinished( 563 arc_session_manager()->OnProvisioningFinished(
568 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); 564 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
569 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); 565 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
570 566
571 arc_session_manager()->Shutdown(); 567 arc_session_manager()->Shutdown();
572 } 568 }
573 569
574 class ArcSessionManagerPolicyTest
575 : public ArcSessionManagerTest,
576 public testing::WithParamInterface<std::tuple<base::Value, base::Value>> {
577 public:
578 const base::Value& backup_restore_pref_value() const {
579 return std::get<0>(GetParam());
580 }
581
582 const base::Value& location_service_pref_value() const {
583 return std::get<1>(GetParam());
584 }
585 };
586
587 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) {
588 sync_preferences::TestingPrefServiceSyncable* const prefs =
589 profile()->GetTestingPrefService();
590
591 // Backup-restore and location-service prefs are off by default.
592 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn));
593 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted));
594
595 // Set ARC to be managed.
596 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true));
597
598 // Assign test values to the prefs.
599 if (backup_restore_pref_value().is_bool()) {
600 prefs->SetManagedPref(prefs::kArcBackupRestoreEnabled,
601 backup_restore_pref_value().DeepCopy());
602 }
603 if (location_service_pref_value().is_bool()) {
604 prefs->SetManagedPref(prefs::kArcLocationServiceEnabled,
605 location_service_pref_value().DeepCopy());
606 }
607
608 arc_session_manager()->OnPrimaryUserProfilePrepared(profile());
609 EXPECT_TRUE(arc_session_manager()->IsArcPlayStoreEnabled());
610 EXPECT_TRUE(arc_session_manager()->IsArcManaged());
611
612 // Terms of Service should be skipped if both ArcBackupRestoreEnabled and
613 // ArcLocationServiceEnabled are managed.
614 const ArcSessionManager::State expected_state =
615 backup_restore_pref_value().is_bool() &&
616 location_service_pref_value().is_bool()
617 ? ArcSessionManager::State::ACTIVE
618 : ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE;
619 EXPECT_EQ(expected_state, arc_session_manager()->state());
620
621 // Managed values for the prefs are unset.
622 prefs->RemoveManagedPref(prefs::kArcBackupRestoreEnabled);
623 prefs->RemoveManagedPref(prefs::kArcLocationServiceEnabled);
624
625 // The ARC state is preserved. The prefs return to the default false values.
626 EXPECT_EQ(expected_state, arc_session_manager()->state());
627 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled));
628 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled));
629
630 // Stop ARC and shutdown the service.
631 prefs->RemoveManagedPref(prefs::kArcEnabled);
632 WaitForDataRemoved(ArcSessionManager::State::STOPPED);
633 arc_session_manager()->Shutdown();
634 }
635
636 INSTANTIATE_TEST_CASE_P(
637 ArcSessionManagerPolicyTest,
638 ArcSessionManagerPolicyTest,
639 testing::Combine(
640 testing::Values(base::Value(), base::Value(false), base::Value(true)),
641 testing::Values(base::Value(), base::Value(false), base::Value(true))));
642
643 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase { 570 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase {
644 public: 571 public:
645 ArcSessionManagerKioskTest() = default; 572 ArcSessionManagerKioskTest() = default;
646 573
647 void SetUp() override { 574 void SetUp() override {
648 ArcSessionManagerTestBase::SetUp(); 575 ArcSessionManagerTestBase::SetUp();
649 const AccountId account_id( 576 const AccountId account_id(
650 AccountId::FromUserEmail(profile()->GetProfileUserName())); 577 AccountId::FromUserEmail(profile()->GetProfileUserName()));
651 GetFakeUserManager()->AddArcKioskAppUser(account_id); 578 GetFakeUserManager()->AddArcKioskAppUser(account_id);
652 GetFakeUserManager()->LoginUser(account_id); 579 GetFakeUserManager()->LoginUser(account_id);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 774 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
848 arc_session_manager()->state()); 775 arc_session_manager()->state());
849 CloseLoginDisplayHost(); 776 CloseLoginDisplayHost();
850 ReportActorDestroyed(); 777 ReportActorDestroyed();
851 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); 778 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state());
852 EXPECT_FALSE(!IsManagedUser() && 779 EXPECT_FALSE(!IsManagedUser() &&
853 arc_session_manager()->IsArcPlayStoreEnabled()); 780 arc_session_manager()->IsArcPlayStoreEnabled());
854 } 781 }
855 782
856 } // namespace arc 783 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.cc ('k') | chrome/browser/chromeos/arc/extensions/fake_arc_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698