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

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

Issue 2668153002: Revert of Move more utility functions to arc_util. (Closed)
Patch Set: Created 3 years, 11 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
deleted file mode 100644
index 9c7bd6e423ad4b0cb720eeb0015630334839ddc1..0000000000000000000000000000000000000000
--- a/chrome/browser/chromeos/arc/arc_util_unittest.cc
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/chromeos/arc/arc_util.h"
-
-#include <memory>
-
-#include "base/command_line.h"
-#include "base/macros.h"
-#include "base/memory/ptr_util.h"
-#include "base/test/scoped_command_line.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/test/base/testing_profile.h"
-#include "components/signin/core/account_id/account_id.h"
-#include "components/user_manager/user_manager.h"
-#include "content/public/test/test_browser_thread_bundle.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace arc {
-namespace util {
-
-namespace {
-
-constexpr char kTestProfileName[] = "user@gmail.com";
-constexpr char kTestGaiaId[] = "1234567890";
-
-class ScopedLogIn {
- public:
- ScopedLogIn(
- chromeos::FakeChromeUserManager* fake_user_manager,
- const AccountId& account_id,
- user_manager::UserType user_type = user_manager::USER_TYPE_REGULAR)
- : fake_user_manager_(fake_user_manager), account_id_(account_id) {
- switch (user_type) {
- case user_manager::USER_TYPE_REGULAR:
- LogIn();
- break;
- case user_manager::USER_TYPE_ARC_KIOSK_APP:
- LogInArcKioskApp();
- break;
- default:
- NOTREACHED();
- }
- }
-
- ~ScopedLogIn() { LogOut(); }
-
- private:
- void LogIn() {
- fake_user_manager_->AddUser(account_id_);
- fake_user_manager_->LoginUser(account_id_);
- }
-
- void LogInArcKioskApp() {
- fake_user_manager_->AddArcKioskAppUser(account_id_);
- fake_user_manager_->LoginUser(account_id_);
- }
-
- void LogOut() { fake_user_manager_->RemoveUserFromList(account_id_); }
-
- chromeos::FakeChromeUserManager* fake_user_manager_;
- const AccountId account_id_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedLogIn);
-};
-
-} // namespace
-
-class ChromeArcUtilTest : public testing::Test {
- public:
- ChromeArcUtilTest() = default;
- ~ChromeArcUtilTest() override = default;
-
- void SetUp() override {
- command_line_ = base::MakeUnique<base::test::ScopedCommandLine>();
- command_line_->GetProcessCommandLine()->InitFromArgv({"", "--enable-arc"});
-
- user_manager_enabler_ =
- base::MakeUnique<chromeos::ScopedUserManagerEnabler>(
- new chromeos::FakeChromeUserManager());
- chromeos::WallpaperManager::Initialize();
- profile_ = base::MakeUnique<TestingProfile>();
- profile_->set_profile_name(kTestProfileName);
- }
-
- void TearDown() override {
- profile_.reset();
- chromeos::WallpaperManager::Shutdown();
- user_manager_enabler_.reset();
- command_line_.reset();
- }
-
- TestingProfile* profile() { return profile_.get(); }
-
- chromeos::FakeChromeUserManager* GetFakeUserManager() const {
- return static_cast<chromeos::FakeChromeUserManager*>(
- user_manager::UserManager::Get());
- }
-
- void LogIn() {
- const auto account_id = AccountId::FromUserEmailGaiaId(
- profile()->GetProfileUserName(), kTestGaiaId);
- GetFakeUserManager()->AddUser(account_id);
- GetFakeUserManager()->LoginUser(account_id);
- }
-
- private:
- std::unique_ptr<base::test::ScopedCommandLine> command_line_;
- content::TestBrowserThreadBundle thread_bundle_;
- std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
- std::unique_ptr<TestingProfile> profile_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeArcUtilTest);
-};
-
-TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile) {
- ScopedLogIn login(GetFakeUserManager(),
- AccountId::FromUserEmailGaiaId(
- profile()->GetProfileUserName(), kTestGaiaId));
- EXPECT_TRUE(IsArcAllowedForProfile(profile()));
-
- // false for nullptr.
- EXPECT_FALSE(IsArcAllowedForProfile(nullptr));
-
- // false for incognito mode profile.
- EXPECT_FALSE(IsArcAllowedForProfile(profile()->GetOffTheRecordProfile()));
-
- // false for Legacy supervised user.
- profile()->SetSupervisedUserId("foo");
- EXPECT_FALSE(IsArcAllowedForProfile(profile()));
-}
-
-TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_DisableArc) {
- base::CommandLine::ForCurrentProcess()->InitFromArgv({""});
- ScopedLogIn login(GetFakeUserManager(),
- AccountId::FromUserEmailGaiaId(
- profile()->GetProfileUserName(), kTestGaiaId));
- EXPECT_FALSE(IsArcAllowedForProfile(profile()));
-}
-
-TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_NonPrimaryProfile) {
- ScopedLogIn login2(
- GetFakeUserManager(),
- AccountId::FromUserEmailGaiaId("user2@gmail.com", "0123456789"));
- ScopedLogIn login(GetFakeUserManager(),
- AccountId::FromUserEmailGaiaId(
- profile()->GetProfileUserName(), kTestGaiaId));
- EXPECT_FALSE(IsArcAllowedForProfile(profile()));
-}
-
-TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_Kiosk) {
- ScopedLogIn login(GetFakeUserManager(),
- AccountId::FromUserEmail(profile()->GetProfileUserName()),
- user_manager::USER_TYPE_ARC_KIOSK_APP);
- EXPECT_FALSE(chromeos::ProfileHelper::Get()
- ->GetUserByProfile(profile())
- ->HasGaiaAccount());
- EXPECT_TRUE(IsArcAllowedForProfile(profile()));
-}
-
-TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_SupervisedUserFlow) {
- auto manager_id = AccountId::FromUserEmailGaiaId(
- profile()->GetProfileUserName(), kTestGaiaId);
- ScopedLogIn login(GetFakeUserManager(), manager_id);
- GetFakeUserManager()->SetUserFlow(
- manager_id, new chromeos::SupervisedUserCreationFlow(manager_id));
- EXPECT_FALSE(IsArcAllowedForProfile(profile()));
-}
-
-// TODO(hidehiko): Add test for Ephemeral users. There seems no way to easily
-// simulate ephemeral user.
-
-} // namespace util
-} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/arc_util.cc ('k') | chrome/browser/chromeos/extensions/file_manager/event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698