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