| Index: chrome/browser/ui/app_list/arc/arc_app_test.cc
|
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_test.cc b/chrome/browser/ui/app_list/arc/arc_app_test.cc
|
| index 830272130f3b6ced40aed1101d1dc47ac64e786c..58b683fe3acfec83ec408fe5c8cdd9bdbd557094 100644
|
| --- a/chrome/browser/ui/app_list/arc/arc_app_test.cc
|
| +++ b/chrome/browser/ui/app_list/arc/arc_app_test.cc
|
| @@ -41,6 +41,7 @@ std::string ArcAppTest::GetAppId(const arc::mojom::ShortcutInfo& shortcut) {
|
| ArcAppTest::ArcAppTest() {
|
| user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler(
|
| new chromeos::FakeChromeUserManager()));
|
| + CreateFakeAppsAndPackages();
|
| }
|
|
|
| ArcAppTest::~ArcAppTest() {
|
| @@ -67,6 +68,37 @@ void ArcAppTest::SetUp(Profile* profile) {
|
| // profile manager (which is null).
|
| chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user,
|
| profile_);
|
| +
|
| + // A valid |arc_app_list_prefs_| is needed for the Arc bridge service and the
|
| + // Arc auth service.
|
| + arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
|
| + if (!arc_app_list_pref_) {
|
| + ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting(
|
| + profile_);
|
| + }
|
| + bridge_service_.reset(new arc::FakeArcBridgeService());
|
| +
|
| + arc_session_manager_.reset(new arc::ArcSessionManager(bridge_service_.get()));
|
| + DCHECK(arc::ArcSessionManager::Get());
|
| + arc::ArcSessionManager::DisableUIForTesting();
|
| + arc_session_manager_->OnPrimaryUserProfilePrepared(profile_);
|
| +
|
| + arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
|
| + DCHECK(arc_app_list_pref_);
|
| + base::RunLoop run_loop;
|
| + arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure());
|
| + run_loop.Run();
|
| +
|
| + arc_session_manager_->EnableArc();
|
| + app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
|
| + bridge_service_->app()->SetInstance(app_instance_.get());
|
| +
|
| + // Check initial conditions.
|
| + EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get());
|
| + EXPECT_FALSE(arc::ArcBridgeService::Get()->ready());
|
| +}
|
| +
|
| +void ArcAppTest::CreateFakeAppsAndPackages() {
|
| arc::mojom::AppInfo app;
|
| // Make sure we have enough data for test.
|
| for (int i = 0; i < 3; ++i) {
|
| @@ -124,38 +156,12 @@ void ArcAppTest::SetUp(Profile* profile) {
|
| base::StringPrintf("fake.shortcut.%d.icon_resource_id", i);
|
| fake_shortcuts_.push_back(shortcutInfo);
|
| }
|
| -
|
| - // A valid |arc_app_list_prefs_| is needed for the Arc bridge service and the
|
| - // Arc auth service.
|
| - arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
|
| - if (!arc_app_list_pref_) {
|
| - ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting(
|
| - profile_);
|
| - }
|
| - bridge_service_.reset(new arc::FakeArcBridgeService());
|
| -
|
| - arc_session_manager_.reset(new arc::ArcSessionManager(bridge_service_.get()));
|
| - DCHECK(arc::ArcSessionManager::Get());
|
| - arc::ArcSessionManager::DisableUIForTesting();
|
| - arc_session_manager_->OnPrimaryUserProfilePrepared(profile_);
|
| -
|
| - arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
|
| - DCHECK(arc_app_list_pref_);
|
| - base::RunLoop run_loop;
|
| - arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure());
|
| - run_loop.Run();
|
| -
|
| - arc_session_manager_->EnableArc();
|
| - app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
|
| - bridge_service_->app()->SetInstance(app_instance_.get());
|
| -
|
| - // Check initial conditions.
|
| - EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get());
|
| - EXPECT_FALSE(arc::ArcBridgeService::Get()->ready());
|
| }
|
|
|
| void ArcAppTest::TearDown() {
|
| + app_instance_.reset();
|
| arc_session_manager_.reset();
|
| + bridge_service_.reset();
|
| if (dbus_thread_manager_initialized_) {
|
| // DBusThreadManager may be initialized from other testing utility,
|
| // such as ash::test::AshTestHelper::SetUp(), so Shutdown() only when
|
| @@ -163,6 +169,7 @@ void ArcAppTest::TearDown() {
|
| chromeos::DBusThreadManager::Shutdown();
|
| dbus_thread_manager_initialized_ = false;
|
| }
|
| + profile_ = nullptr;
|
| }
|
|
|
| void ArcAppTest::StopArcInstance() {
|
|
|