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

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

Issue 2742013002: Don't skip ARC ToS due to policies if ArcEnabled is not managed (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 7 #include <tuple>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null()); 469 EXPECT_FALSE(arc_session_manager()->arc_start_time().is_null());
470 470
471 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); 471 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
472 ASSERT_TRUE(arc_session_manager()->IsSessionRunning()); 472 ASSERT_TRUE(arc_session_manager()->IsSessionRunning());
473 473
474 arc_session_manager()->Shutdown(); 474 arc_session_manager()->Shutdown();
475 } 475 }
476 476
477 class ArcSessionManagerPolicyTest 477 class ArcSessionManagerPolicyTest
478 : public ArcSessionManagerTest, 478 : public ArcSessionManagerTest,
479 public testing::WithParamInterface<std::tuple<base::Value, base::Value>> { 479 public testing::WithParamInterface<
480 std::tuple<bool, base::Value, base::Value>> {
480 public: 481 public:
482 bool arc_enabled_pref_managed() const { return std::get<0>(GetParam()); }
483
481 const base::Value& backup_restore_pref_value() const { 484 const base::Value& backup_restore_pref_value() const {
482 return std::get<0>(GetParam()); 485 return std::get<1>(GetParam());
483 } 486 }
484 487
485 const base::Value& location_service_pref_value() const { 488 const base::Value& location_service_pref_value() const {
486 return std::get<1>(GetParam()); 489 return std::get<2>(GetParam());
487 } 490 }
488 }; 491 };
489 492
490 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) { 493 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) {
491 sync_preferences::TestingPrefServiceSyncable* const prefs = 494 sync_preferences::TestingPrefServiceSyncable* const prefs =
492 profile()->GetTestingPrefService(); 495 profile()->GetTestingPrefService();
493 496
494 // Backup-restore and location-service prefs are off by default. 497 // Backup-restore and location-service prefs are off by default.
495 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); 498 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn));
496 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted)); 499 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted));
497 500
498 // Set ARC to be managed. 501 // Enable ARC through user pref or by policy, according to the test parameter.
499 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true)); 502 if (arc_enabled_pref_managed())
503 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true));
504 else
505 prefs->SetBoolean(prefs::kArcEnabled, true);
506 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
500 507
501 // Assign test values to the prefs. 508 // Assign test values to the prefs.
502 if (backup_restore_pref_value().is_bool()) { 509 if (backup_restore_pref_value().is_bool()) {
503 prefs->SetManagedPref(prefs::kArcBackupRestoreEnabled, 510 prefs->SetManagedPref(prefs::kArcBackupRestoreEnabled,
504 backup_restore_pref_value().DeepCopy()); 511 backup_restore_pref_value().DeepCopy());
505 } 512 }
506 if (location_service_pref_value().is_bool()) { 513 if (location_service_pref_value().is_bool()) {
507 prefs->SetManagedPref(prefs::kArcLocationServiceEnabled, 514 prefs->SetManagedPref(prefs::kArcLocationServiceEnabled,
508 location_service_pref_value().DeepCopy()); 515 location_service_pref_value().DeepCopy());
509 } 516 }
510 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
511 EXPECT_TRUE(arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile()));
512 517
513 arc_session_manager()->SetProfile(profile()); 518 arc_session_manager()->SetProfile(profile());
514 arc_session_manager()->RequestEnable(); 519 arc_session_manager()->RequestEnable();
515 520
516 // Terms of Service are skipped if both ArcBackupRestoreEnabled and 521 // Terms of Service are skipped iff ARC is enabled by policy and both
517 // ArcLocationServiceEnabled are managed. 522 // ArcBackupRestoreEnabled and ArcLocationServiceEnabled are managed.
518 const bool expected_terms_skipping = backup_restore_pref_value().is_bool() && 523 const bool expected_terms_skipping = arc_enabled_pref_managed() &&
524 backup_restore_pref_value().is_bool() &&
519 location_service_pref_value().is_bool(); 525 location_service_pref_value().is_bool();
520 EXPECT_EQ(expected_terms_skipping 526 EXPECT_EQ(expected_terms_skipping
521 ? ArcSessionManager::State::ACTIVE 527 ? ArcSessionManager::State::ACTIVE
522 : ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 528 : ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
523 arc_session_manager()->state()); 529 arc_session_manager()->state());
524 530
525 // Complete provisioning if it's not done yet. 531 // Complete provisioning if it's not done yet.
526 if (!expected_terms_skipping) { 532 if (!expected_terms_skipping) {
527 arc_session_manager()->StartArcForTesting(); 533 arc_session_manager()->StartArcForTesting();
528 arc_session_manager()->OnProvisioningFinished(ProvisioningResult::SUCCESS); 534 arc_session_manager()->OnProvisioningFinished(ProvisioningResult::SUCCESS);
(...skipping 17 matching lines...) Expand all
546 // Stop ARC and shutdown the service. 552 // Stop ARC and shutdown the service.
547 prefs->RemoveManagedPref(prefs::kArcEnabled); 553 prefs->RemoveManagedPref(prefs::kArcEnabled);
548 WaitForDataRemoved(ArcSessionManager::State::STOPPED); 554 WaitForDataRemoved(ArcSessionManager::State::STOPPED);
549 arc_session_manager()->Shutdown(); 555 arc_session_manager()->Shutdown();
550 } 556 }
551 557
552 INSTANTIATE_TEST_CASE_P( 558 INSTANTIATE_TEST_CASE_P(
553 ArcSessionManagerPolicyTest, 559 ArcSessionManagerPolicyTest,
554 ArcSessionManagerPolicyTest, 560 ArcSessionManagerPolicyTest,
555 testing::Combine( 561 testing::Combine(
556 testing::Values(base::Value(), base::Value(false), base::Value(true)), 562 testing::Values(false, true) /* arc_enabled_pref_managed */,
557 testing::Values(base::Value(), base::Value(false), base::Value(true)))); 563 testing::Values(base::Value(),
564 base::Value(false),
565 base::Value(true)) /* backup_restore_pref_value */,
566 testing::Values(base::Value(),
567 base::Value(false),
568 base::Value(true)) /* location_service_pref_value */));
558 569
559 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase { 570 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase {
560 public: 571 public:
561 ArcSessionManagerKioskTest() = default; 572 ArcSessionManagerKioskTest() = default;
562 573
563 void SetUp() override { 574 void SetUp() override {
564 ArcSessionManagerTestBase::SetUp(); 575 ArcSessionManagerTestBase::SetUp();
565 const AccountId account_id( 576 const AccountId account_id(
566 AccountId::FromUserEmail(profile()->GetProfileUserName())); 577 AccountId::FromUserEmail(profile()->GetProfileUserName()));
567 GetFakeUserManager()->AddArcKioskAppUser(account_id); 578 GetFakeUserManager()->AddArcKioskAppUser(account_id);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should 769 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should
759 // be kept as is. 770 // be kept as is.
760 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 771 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
761 arc_session_manager()->state()); 772 arc_session_manager()->state());
762 // Managed user's preference should not be overwritten. 773 // Managed user's preference should not be overwritten.
763 if (!IsManagedUser()) 774 if (!IsManagedUser())
764 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); 775 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
765 } 776 }
766 777
767 } // namespace arc 778 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698