| 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 "chrome/browser/ui/app_list/arc/arc_app_test.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 11 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 12 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 12 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 15 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 15 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 16 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
| 16 #include "chromeos/chromeos_switches.h" | 17 #include "chromeos/chromeos_switches.h" |
| 17 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
| 18 #include "components/arc/arc_bridge_service.h" | 19 #include "components/arc/arc_bridge_service.h" |
| 19 #include "components/arc/test/fake_app_instance.h" | 20 #include "components/arc/test/fake_app_instance.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 127 |
| 127 // A valid |arc_app_list_prefs_| is needed for the Arc bridge service and the | 128 // A valid |arc_app_list_prefs_| is needed for the Arc bridge service and the |
| 128 // Arc auth service. | 129 // Arc auth service. |
| 129 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 130 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
| 130 if (!arc_app_list_pref_) { | 131 if (!arc_app_list_pref_) { |
| 131 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting( | 132 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting( |
| 132 profile_); | 133 profile_); |
| 133 } | 134 } |
| 134 bridge_service_.reset(new arc::FakeArcBridgeService()); | 135 bridge_service_.reset(new arc::FakeArcBridgeService()); |
| 135 | 136 |
| 136 auth_service_.reset(new arc::ArcAuthService(bridge_service_.get())); | 137 arc_session_manager_.reset(new arc::ArcSessionManager(bridge_service_.get())); |
| 137 DCHECK(arc::ArcAuthService::Get()); | 138 DCHECK(arc::ArcSessionManager::Get()); |
| 138 arc::ArcAuthService::DisableUIForTesting(); | 139 arc::ArcSessionManager::DisableUIForTesting(); |
| 139 arc_auth_service()->OnPrimaryUserProfilePrepared(profile_); | 140 arc_session_manager_->OnPrimaryUserProfilePrepared(profile_); |
| 140 | 141 |
| 141 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 142 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
| 142 DCHECK(arc_app_list_pref_); | 143 DCHECK(arc_app_list_pref_); |
| 143 base::RunLoop run_loop; | 144 base::RunLoop run_loop; |
| 144 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | 145 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 145 run_loop.Run(); | 146 run_loop.Run(); |
| 146 | 147 |
| 147 auth_service_->EnableArc(); | 148 arc_session_manager_->EnableArc(); |
| 148 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); | 149 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); |
| 149 bridge_service_->app()->SetInstance(app_instance_.get()); | 150 bridge_service_->app()->SetInstance(app_instance_.get()); |
| 150 | 151 |
| 151 // Check initial conditions. | 152 // Check initial conditions. |
| 152 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); | 153 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); |
| 153 EXPECT_FALSE(arc::ArcBridgeService::Get()->ready()); | 154 EXPECT_FALSE(arc::ArcBridgeService::Get()->ready()); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void ArcAppTest::TearDown() { | 157 void ArcAppTest::TearDown() { |
| 157 auth_service_.reset(); | 158 arc_session_manager_.reset(); |
| 158 if (dbus_thread_manager_initialized_) { | 159 if (dbus_thread_manager_initialized_) { |
| 159 // DBusThreadManager may be initialized from other testing utility, | 160 // DBusThreadManager may be initialized from other testing utility, |
| 160 // such as ash::test::AshTestHelper::SetUp(), so Shutdown() only when | 161 // such as ash::test::AshTestHelper::SetUp(), so Shutdown() only when |
| 161 // it is initialized in ArcAppTest::SetUp(). | 162 // it is initialized in ArcAppTest::SetUp(). |
| 162 chromeos::DBusThreadManager::Shutdown(); | 163 chromeos::DBusThreadManager::Shutdown(); |
| 163 dbus_thread_manager_initialized_ = false; | 164 dbus_thread_manager_initialized_ = false; |
| 164 } | 165 } |
| 165 } | 166 } |
| 166 | 167 |
| 167 void ArcAppTest::StopArcInstance() { | 168 void ArcAppTest::StopArcInstance() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 197 } | 198 } |
| 198 } | 199 } |
| 199 | 200 |
| 200 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { | 201 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { |
| 201 for (auto fake_package : fake_packages_) { | 202 for (auto fake_package : fake_packages_) { |
| 202 if (package.package_name == fake_package.package_name) | 203 if (package.package_name == fake_package.package_name) |
| 203 return true; | 204 return true; |
| 204 } | 205 } |
| 205 return false; | 206 return false; |
| 206 } | 207 } |
| OLD | NEW |