| OLD | NEW |
| 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" | |
| 29 #include "chromeos/login/user_names.h" | 28 #include "chromeos/login/user_names.h" |
| 30 #include "components/arc/arc_bridge_service.h" | 29 #include "components/arc/arc_bridge_service.h" |
| 31 #include "components/arc/test/fake_arc_bridge_service.h" | 30 #include "components/arc/test/fake_arc_bridge_service.h" |
| 32 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
| 33 #include "components/signin/core/account_id/account_id.h" | 32 #include "components/signin/core/account_id/account_id.h" |
| 34 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 33 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 35 #include "components/user_manager/user_manager.h" | 34 #include "components/user_manager/user_manager.h" |
| 36 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/test/test_browser_thread_bundle.h" | 36 #include "content/public/test/test_browser_thread_bundle.h" |
| 38 #include "google_apis/gaia/gaia_constants.h" | 37 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 52 } // namespace | 51 } // namespace |
| 53 | 52 |
| 54 class ArcAuthServiceTest : public testing::Test { | 53 class ArcAuthServiceTest : public testing::Test { |
| 55 public: | 54 public: |
| 56 ArcAuthServiceTest() | 55 ArcAuthServiceTest() |
| 57 : thread_bundle_(new content::TestBrowserThreadBundle(kThreadOptions)), | 56 : thread_bundle_(new content::TestBrowserThreadBundle(kThreadOptions)), |
| 58 user_manager_enabler_(new chromeos::FakeChromeUserManager) {} | 57 user_manager_enabler_(new chromeos::FakeChromeUserManager) {} |
| 59 ~ArcAuthServiceTest() override = default; | 58 ~ArcAuthServiceTest() override = default; |
| 60 | 59 |
| 61 void SetUp() override { | 60 void SetUp() override { |
| 62 chromeos::DBusThreadManager::Initialize(); | |
| 63 | |
| 64 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 61 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 65 chromeos::switches::kEnableArc); | 62 chromeos::switches::kEnableArc); |
| 66 ArcAuthService::DisableUIForTesting(); | 63 ArcAuthService::DisableUIForTesting(); |
| 67 | 64 |
| 68 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 65 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 69 TestingProfile::Builder profile_builder; | 66 TestingProfile::Builder profile_builder; |
| 70 profile_builder.SetPath(temp_dir_.path().AppendASCII("TestArcProfile")); | 67 profile_builder.SetPath(temp_dir_.path().AppendASCII("TestArcProfile")); |
| 71 | 68 |
| 72 profile_ = profile_builder.Build(); | 69 profile_ = profile_builder.Build(); |
| 73 StartPreferenceSyncing(); | 70 StartPreferenceSyncing(); |
| 74 | 71 |
| 75 bridge_service_.reset(new FakeArcBridgeService()); | 72 bridge_service_.reset(new FakeArcBridgeService()); |
| 76 auth_service_.reset(new ArcAuthService(bridge_service_.get())); | 73 auth_service_.reset(new ArcAuthService(bridge_service_.get())); |
| 77 | 74 |
| 78 // Check initial conditions. | 75 // Check initial conditions. |
| 79 EXPECT_EQ(bridge_service_.get(), ArcBridgeService::Get()); | 76 EXPECT_EQ(bridge_service_.get(), ArcBridgeService::Get()); |
| 80 EXPECT_EQ(true, !ArcBridgeService::Get()->available()); | 77 EXPECT_EQ(true, !ArcBridgeService::Get()->available()); |
| 81 EXPECT_EQ(ArcBridgeService::State::STOPPED, | 78 EXPECT_EQ(ArcBridgeService::State::STOPPED, |
| 82 ArcBridgeService::Get()->state()); | 79 ArcBridgeService::Get()->state()); |
| 83 | 80 |
| 84 const AccountId account_id( | 81 const AccountId account_id( |
| 85 AccountId::FromUserEmailGaiaId("user@gmail.com", "1234567890")); | 82 AccountId::FromUserEmailGaiaId("user@gmail.com", "1234567890")); |
| 86 GetFakeUserManager()->AddUser(account_id); | 83 GetFakeUserManager()->AddUser(account_id); |
| 87 GetFakeUserManager()->LoginUser(account_id); | 84 GetFakeUserManager()->LoginUser(account_id); |
| 88 | 85 |
| 89 chromeos::WallpaperManager::Initialize(); | 86 chromeos::WallpaperManager::Initialize(); |
| 90 } | 87 } |
| 91 | 88 |
| 92 void TearDown() override { | 89 void TearDown() override { chromeos::WallpaperManager::Shutdown(); } |
| 93 chromeos::WallpaperManager::Shutdown(); | |
| 94 chromeos::DBusThreadManager::Shutdown(); | |
| 95 } | |
| 96 | 90 |
| 97 chromeos::FakeChromeUserManager* GetFakeUserManager() const { | 91 chromeos::FakeChromeUserManager* GetFakeUserManager() const { |
| 98 return static_cast<chromeos::FakeChromeUserManager*>( | 92 return static_cast<chromeos::FakeChromeUserManager*>( |
| 99 user_manager::UserManager::Get()); | 93 user_manager::UserManager::Get()); |
| 100 } | 94 } |
| 101 | 95 |
| 102 protected: | 96 protected: |
| 103 Profile* profile() { return profile_.get(); } | 97 Profile* profile() { return profile_.get(); } |
| 104 FakeArcBridgeService* bridge_service() { return bridge_service_.get(); } | 98 FakeArcBridgeService* bridge_service() { return bridge_service_.get(); } |
| 105 ArcAuthService* auth_service() { return auth_service_.get(); } | 99 ArcAuthService* auth_service() { return auth_service_.get(); } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 second_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); | 356 second_profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
| 363 | 357 |
| 364 // Check that non-primary user can't use Arc. | 358 // Check that non-primary user can't use Arc. |
| 365 EXPECT_FALSE(chromeos::ProfileHelper::IsPrimaryProfile(second_profile.get())); | 359 EXPECT_FALSE(chromeos::ProfileHelper::IsPrimaryProfile(second_profile.get())); |
| 366 EXPECT_FALSE(ArcAppListPrefs::Get(second_profile.get())); | 360 EXPECT_FALSE(ArcAppListPrefs::Get(second_profile.get())); |
| 367 | 361 |
| 368 auth_service()->Shutdown(); | 362 auth_service()->Shutdown(); |
| 369 } | 363 } |
| 370 | 364 |
| 371 } // namespace arc | 365 } // namespace arc |
| OLD | NEW |