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

Unified Diff: chrome/browser/chromeos/arc/arc_util_unittest.cc

Issue 2702723002: Extract kArcEnabled preference from ArcSessionManager part 1. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_util_unittest.cc
diff --git a/chrome/browser/chromeos/arc/arc_util_unittest.cc b/chrome/browser/chromeos/arc/arc_util_unittest.cc
index 7b2018e5e1c85ec4cd3ac842f959e2829aa53a17..b88915600903317b36979dafdaa5ce3c063bf8d3 100644
--- a/chrome/browser/chromeos/arc/arc_util_unittest.cc
+++ b/chrome/browser/chromeos/arc/arc_util_unittest.cc
@@ -10,14 +10,18 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/test/scoped_command_line.h"
+#include "base/values.h"
#include "chrome/browser/chromeos/login/supervised/supervised_user_creation_flow.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/prefs/pref_service.h"
#include "components/signin/core/account_id/account_id.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/user_manager/user_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -225,5 +229,63 @@ TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_SupervisedUserFlow) {
// TODO(hidehiko): Add test for Ephemeral users. There seems no way to easily
// simulate ephemeral user.
+TEST_F(ChromeArcUtilTest, ArcPlayStoreEnabledForProfile) {
+ // Ensure IsAllowedForProfile() true.
+ ScopedLogIn login(GetFakeUserManager(),
+ AccountId::FromUserEmailGaiaId(
+ profile()->GetProfileUserName(), kTestGaiaId));
+ ASSERT_TRUE(IsArcAllowedForProfile(profile()));
+
+ // By default, Google Play Store is disabled.
+ EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
+
+ // Enable Google Play Store.
+ SetArcPlayStoreEnabledForProfile(profile(), true);
+ EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
+
+ // Disable Google Play Store.
+ SetArcPlayStoreEnabledForProfile(profile(), false);
+ EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
+}
+
+TEST_F(ChromeArcUtilTest, ArcPlayStoreEnabledForProfile_NotAllowed) {
+ ASSERT_FALSE(IsArcAllowedForProfile(profile()));
+
+ // If ARC is not allowed for the profile, always return false.
+ EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
+
+ // Directly set the preference value, to avoid DCHECK in
+ // SetArcPlayStoreEnabledForProfile().
+ profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true);
+ EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
+}
+
+TEST_F(ChromeArcUtilTest, ArcPlayStoreEnabledForProfile_Managed) {
+ // Ensure IsAllowedForProfile() true.
+ ScopedLogIn login(GetFakeUserManager(),
+ AccountId::FromUserEmailGaiaId(
+ profile()->GetProfileUserName(), kTestGaiaId));
+ ASSERT_TRUE(IsArcAllowedForProfile(profile()));
+
+ // By default it is not managed.
+ EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
+ EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
+
+ // Set managed preference to true.
+ profile()->GetTestingPrefService()->SetManagedPref(prefs::kArcEnabled,
+ new base::Value(true));
+ EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
+ EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
+
+ // In managed case, SetArcPlayStoreEnabledForProfile() does nothing.
+ SetArcPlayStoreEnabledForProfile(profile(), false);
Yusuke Sato 2017/02/17 22:27:09 nit: can you also test that SetArcPlayStoreEnabled
hidehiko 2017/02/20 18:18:44 Done.
+ EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
+ EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
+
+ // Remove managed state.
+ profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled);
+ EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
+}
+
} // namespace util
} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698