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

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

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/chromeos/arc/arc_util.h" 5 #include "chrome/browser/chromeos/arc/arc_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 AccountId::FromUserEmailGaiaId( 295 AccountId::FromUserEmailGaiaId(
296 profile()->GetProfileUserName(), kTestGaiaId)); 296 profile()->GetProfileUserName(), kTestGaiaId));
297 ASSERT_TRUE(IsArcAllowedForProfile(profile())); 297 ASSERT_TRUE(IsArcAllowedForProfile(profile()));
298 298
299 // By default it is not managed. 299 // By default it is not managed.
300 EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())); 300 EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
301 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); 301 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
302 302
303 // 1) Set managed preference to true, then try to set the value to false 303 // 1) Set managed preference to true, then try to set the value to false
304 // via SetArcPlayStoreEnabledForProfile(). 304 // via SetArcPlayStoreEnabledForProfile().
305 profile()->GetTestingPrefService()->SetManagedPref(prefs::kArcEnabled, 305 profile()->GetTestingPrefService()->SetManagedPref(
306 new base::Value(true)); 306 prefs::kArcEnabled, base::MakeUnique<base::Value>(true));
307 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())); 307 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
308 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile())); 308 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
309 SetArcPlayStoreEnabledForProfile(profile(), false); 309 SetArcPlayStoreEnabledForProfile(profile(), false);
310 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())); 310 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
311 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile())); 311 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
312 312
313 // Remove managed state. 313 // Remove managed state.
314 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); 314 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled);
315 EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())); 315 EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
316 316
317 // 2) Set managed preference to false, then try to set the value to true 317 // 2) Set managed preference to false, then try to set the value to true
318 // via SetArcPlayStoreEnabledForProfile(). 318 // via SetArcPlayStoreEnabledForProfile().
319 profile()->GetTestingPrefService()->SetManagedPref(prefs::kArcEnabled, 319 profile()->GetTestingPrefService()->SetManagedPref(
320 new base::Value(false)); 320 prefs::kArcEnabled, base::MakeUnique<base::Value>(false));
321 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())); 321 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
322 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); 322 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
323 SetArcPlayStoreEnabledForProfile(profile(), true); 323 SetArcPlayStoreEnabledForProfile(profile(), true);
324 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())); 324 EXPECT_TRUE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
325 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); 325 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
326 326
327 // Remove managed state. 327 // Remove managed state.
328 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); 328 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled);
329 EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())); 329 EXPECT_FALSE(IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
330 } 330 }
331 331
332 // Test the AreArcAllOptInPreferencesManagedForProfile() function. 332 // Test the AreArcAllOptInPreferencesManagedForProfile() function.
333 TEST_F(ChromeArcUtilTest, AreArcAllOptInPreferencesManagedForProfile) { 333 TEST_F(ChromeArcUtilTest, AreArcAllOptInPreferencesManagedForProfile) {
334 // OptIn prefs are unset, the function returns false. 334 // OptIn prefs are unset, the function returns false.
335 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile())); 335 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile()));
336 336
337 // OptIn prefs are set to unmanaged values, and the function returns false. 337 // OptIn prefs are set to unmanaged values, and the function returns false.
338 profile()->GetPrefs()->SetBoolean(prefs::kArcBackupRestoreEnabled, false); 338 profile()->GetPrefs()->SetBoolean(prefs::kArcBackupRestoreEnabled, false);
339 profile()->GetPrefs()->SetBoolean(prefs::kArcLocationServiceEnabled, false); 339 profile()->GetPrefs()->SetBoolean(prefs::kArcLocationServiceEnabled, false);
340 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile())); 340 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile()));
341 341
342 // Backup-restore pref is managed, while location-service is not, and the 342 // Backup-restore pref is managed, while location-service is not, and the
343 // function returns false. 343 // function returns false.
344 profile()->GetTestingPrefService()->SetManagedPref( 344 profile()->GetTestingPrefService()->SetManagedPref(
345 prefs::kArcBackupRestoreEnabled, new base::Value(false)); 345 prefs::kArcBackupRestoreEnabled, base::MakeUnique<base::Value>(false));
346 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile())); 346 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile()));
347 347
348 // Location-service pref is managed, while backup-restore is not, and the 348 // Location-service pref is managed, while backup-restore is not, and the
349 // function returns false. 349 // function returns false.
350 profile()->GetTestingPrefService()->RemoveManagedPref( 350 profile()->GetTestingPrefService()->RemoveManagedPref(
351 prefs::kArcBackupRestoreEnabled); 351 prefs::kArcBackupRestoreEnabled);
352 profile()->GetTestingPrefService()->SetManagedPref( 352 profile()->GetTestingPrefService()->SetManagedPref(
353 prefs::kArcLocationServiceEnabled, new base::Value(false)); 353 prefs::kArcLocationServiceEnabled, base::MakeUnique<base::Value>(false));
354 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile())); 354 EXPECT_FALSE(AreArcAllOptInPreferencesManagedForProfile(profile()));
355 355
356 // Both OptIn prefs are set to managed values, and the function returns true. 356 // Both OptIn prefs are set to managed values, and the function returns true.
357 profile()->GetTestingPrefService()->SetManagedPref( 357 profile()->GetTestingPrefService()->SetManagedPref(
358 prefs::kArcBackupRestoreEnabled, new base::Value(false)); 358 prefs::kArcBackupRestoreEnabled, base::MakeUnique<base::Value>(false));
359 EXPECT_TRUE(AreArcAllOptInPreferencesManagedForProfile(profile())); 359 EXPECT_TRUE(AreArcAllOptInPreferencesManagedForProfile(profile()));
360 } 360 }
361 361
362 } // namespace util 362 } // namespace util
363 } // namespace arc 363 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698