Chromium Code Reviews| 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..465290dccaf6e1ec371331c7ce7303aff60e5382 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,34 +156,6 @@ 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() { |
| @@ -163,6 +167,10 @@ void ArcAppTest::TearDown() { |
| chromeos::DBusThreadManager::Shutdown(); |
| dbus_thread_manager_initialized_ = false; |
| } |
| + arc_session_manager_.reset(); |
|
Luis Héctor Chávez
2016/11/22 17:14:14
This was already destroyed a few lines above.
khmel
2016/11/22 18:43:05
Done.
|
| + app_instance_.reset(); |
|
Luis Héctor Chávez
2016/11/22 17:14:14
You should try to delete stuff in the reverse orde
khmel
2016/11/22 18:43:05
Done.
|
| + bridge_service_.reset(); |
|
Luis Héctor Chávez
2016/11/22 17:14:14
And this should be the second line.
khmel
2016/11/22 18:43:05
Done,
As I see this is third line, arc_session_man
|
| + profile_ = nullptr; |
| } |
| void ArcAppTest::StopArcInstance() { |