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

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

Issue 2248353002: [M53 cherry-pick] Migrate ArcUserDataService into ArcAuthService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "chrome/browser/chromeos/arc/arc_auth_service.h" 16 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
17 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 17 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
18 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 18 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
19 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 19 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" 20 #include "chrome/browser/chromeos/profiles/profile_helper.h"
21 #include "chrome/browser/prefs/pref_service_syncable_util.h" 21 #include "chrome/browser/prefs/pref_service_syncable_util.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 23 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
24 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 24 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
27 #include "chromeos/chromeos_switches.h" 27 #include "chromeos/chromeos_switches.h"
28 #include "chromeos/dbus/dbus_thread_manager.h"
28 #include "chromeos/login/user_names.h" 29 #include "chromeos/login/user_names.h"
29 #include "components/arc/arc_bridge_service.h" 30 #include "components/arc/arc_bridge_service.h"
30 #include "components/arc/test/fake_arc_bridge_service.h" 31 #include "components/arc/test/fake_arc_bridge_service.h"
31 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
32 #include "components/signin/core/account_id/account_id.h" 33 #include "components/signin/core/account_id/account_id.h"
33 #include "components/syncable_prefs/testing_pref_service_syncable.h" 34 #include "components/syncable_prefs/testing_pref_service_syncable.h"
34 #include "components/user_manager/user_manager.h" 35 #include "components/user_manager/user_manager.h"
35 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
36 #include "content/public/test/test_browser_thread_bundle.h" 37 #include "content/public/test/test_browser_thread_bundle.h"
37 #include "google_apis/gaia/gaia_constants.h" 38 #include "google_apis/gaia/gaia_constants.h"
(...skipping 13 matching lines...) Expand all
51 } // namespace 52 } // namespace
52 53
53 class ArcAuthServiceTest : public testing::Test { 54 class ArcAuthServiceTest : public testing::Test {
54 public: 55 public:
55 ArcAuthServiceTest() 56 ArcAuthServiceTest()
56 : thread_bundle_(new content::TestBrowserThreadBundle(kThreadOptions)), 57 : thread_bundle_(new content::TestBrowserThreadBundle(kThreadOptions)),
57 user_manager_enabler_(new chromeos::FakeChromeUserManager) {} 58 user_manager_enabler_(new chromeos::FakeChromeUserManager) {}
58 ~ArcAuthServiceTest() override = default; 59 ~ArcAuthServiceTest() override = default;
59 60
60 void SetUp() override { 61 void SetUp() override {
62 chromeos::DBusThreadManager::Initialize();
63
61 base::CommandLine::ForCurrentProcess()->AppendSwitch( 64 base::CommandLine::ForCurrentProcess()->AppendSwitch(
62 chromeos::switches::kEnableArc); 65 chromeos::switches::kEnableArc);
63 ArcAuthService::DisableUIForTesting(); 66 ArcAuthService::DisableUIForTesting();
64 67
65 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 68 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
66 TestingProfile::Builder profile_builder; 69 TestingProfile::Builder profile_builder;
67 profile_builder.SetPath(temp_dir_.path().AppendASCII("TestArcProfile")); 70 profile_builder.SetPath(temp_dir_.path().AppendASCII("TestArcProfile"));
68 71
69 profile_ = profile_builder.Build(); 72 profile_ = profile_builder.Build();
70 StartPreferenceSyncing(); 73 StartPreferenceSyncing();
71 74
72 bridge_service_.reset(new FakeArcBridgeService()); 75 bridge_service_.reset(new FakeArcBridgeService());
73 auth_service_.reset(new ArcAuthService(bridge_service_.get())); 76 auth_service_.reset(new ArcAuthService(bridge_service_.get()));
74 77
75 // Check initial conditions. 78 // Check initial conditions.
76 EXPECT_EQ(bridge_service_.get(), ArcBridgeService::Get()); 79 EXPECT_EQ(bridge_service_.get(), ArcBridgeService::Get());
77 EXPECT_EQ(true, !ArcBridgeService::Get()->available()); 80 EXPECT_EQ(true, !ArcBridgeService::Get()->available());
78 EXPECT_EQ(ArcBridgeService::State::STOPPED, 81 EXPECT_EQ(ArcBridgeService::State::STOPPED,
79 ArcBridgeService::Get()->state()); 82 ArcBridgeService::Get()->state());
80 83
81 const AccountId account_id( 84 const AccountId account_id(
82 AccountId::FromUserEmailGaiaId("user@gmail.com", "1234567890")); 85 AccountId::FromUserEmailGaiaId("user@gmail.com", "1234567890"));
83 GetFakeUserManager()->AddUser(account_id); 86 GetFakeUserManager()->AddUser(account_id);
84 GetFakeUserManager()->LoginUser(account_id); 87 GetFakeUserManager()->LoginUser(account_id);
85 88
86 chromeos::WallpaperManager::Initialize(); 89 chromeos::WallpaperManager::Initialize();
87 } 90 }
88 91
89 void TearDown() override { chromeos::WallpaperManager::Shutdown(); } 92 void TearDown() override {
93 chromeos::WallpaperManager::Shutdown();
94 chromeos::DBusThreadManager::Shutdown();
95 }
90 96
91 chromeos::FakeChromeUserManager* GetFakeUserManager() const { 97 chromeos::FakeChromeUserManager* GetFakeUserManager() const {
92 return static_cast<chromeos::FakeChromeUserManager*>( 98 return static_cast<chromeos::FakeChromeUserManager*>(
93 user_manager::UserManager::Get()); 99 user_manager::UserManager::Get());
94 } 100 }
95 101
96 protected: 102 protected:
97 Profile* profile() { return profile_.get(); } 103 Profile* profile() { return profile_.get(); }
98 FakeArcBridgeService* bridge_service() { return bridge_service_.get(); } 104 FakeArcBridgeService* bridge_service() { return bridge_service_.get(); }
99 ArcAuthService* auth_service() { return auth_service_.get(); } 105 ArcAuthService* auth_service() { return auth_service_.get(); }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 second_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); 362 second_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true);
357 363
358 // Check that non-primary user can't use Arc. 364 // Check that non-primary user can't use Arc.
359 EXPECT_FALSE(chromeos::ProfileHelper::IsPrimaryProfile(second_profile.get())); 365 EXPECT_FALSE(chromeos::ProfileHelper::IsPrimaryProfile(second_profile.get()));
360 EXPECT_FALSE(ArcAppListPrefs::Get(second_profile.get())); 366 EXPECT_FALSE(ArcAppListPrefs::Get(second_profile.get()));
361 367
362 auth_service()->Shutdown(); 368 auth_service()->Shutdown();
363 } 369 }
364 370
365 } // namespace arc 371 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.cc ('k') | chrome/browser/chromeos/arc/arc_enterprise_reporting_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698