Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: chrome/browser/ui/app_list/arc/arc_app_test.cc

Issue 2545533002: [Merge-M56] arc: Fix duplicate icons in app launcher in case of crash. (Closed)
Patch Set: fix resolution Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.h ('k') | chrome/browser/ui/app_list/arc/arc_app_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 41d44f9b7eb8c34b5ec10cb4b62fd1ab18db8f1d..6ffa29cfba0f96b143ff5f81f133e9933ce96990 100644
--- a/chrome/browser/ui/app_list/arc/arc_app_test.cc
+++ b/chrome/browser/ui/app_list/arc/arc_app_test.cc
@@ -40,6 +40,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() {
@@ -66,6 +67,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());
+
+ auth_service_.reset(new arc::ArcAuthService(bridge_service_.get()));
+ DCHECK(arc::ArcAuthService::Get());
+ arc::ArcAuthService::DisableUIForTesting();
+ arc_auth_service()->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();
+
+ auth_service_->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) {
@@ -123,38 +155,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());
-
- auth_service_.reset(new arc::ArcAuthService(bridge_service_.get()));
- DCHECK(arc::ArcAuthService::Get());
- arc::ArcAuthService::DisableUIForTesting();
- arc_auth_service()->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();
-
- auth_service_->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();
auth_service_.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
@@ -162,6 +168,7 @@ void ArcAppTest::TearDown() {
chromeos::DBusThreadManager::Shutdown();
dbus_thread_manager_initialized_ = false;
}
+ profile_ = nullptr;
}
void ArcAppTest::StopArcInstance() {
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.h ('k') | chrome/browser/ui/app_list/arc/arc_app_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698