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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc

Issue 2518423003: Combine shelf platform and windowed app types. (Closed)
Patch Set: Refinements and cleanup. Created 4 years, 1 month 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
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
index 92e680f251bd48334aa9992b2cbdced98e53ce10..23c85d33e032f235c1e17bebb766eaee7100e9db 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
@@ -411,7 +411,7 @@ class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
ash::ShelfID id =
launcher_controller_->CreateAppShortcutLauncherItemWithType(
ash::launcher::AppLauncherId(app_id), model_->item_count(),
- ash::TYPE_PLATFORM_APP);
+ ash::TYPE_APP);
DCHECK(id);
// Change the created launcher controller into a V2 app controller.
test_controller_ = new TestV2AppLauncherItemController(app_id,
@@ -683,94 +683,69 @@ class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
if (!result.empty())
result.append(", ");
switch (model_->items()[i].type) {
- case ash::TYPE_PLATFORM_APP:
- result += "*";
- // FALLTHROUGH
- case ash::TYPE_WINDOWED_APP: {
+ case ash::TYPE_APP: {
+ if (controller()->IsPlatformApp(item().id))
+ result += "*";
const std::string& app =
launcher_controller_->GetAppIDForShelfID(model_->items()[i].id);
- if (app == extension1_->id()) {
- result += "app1";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension1_->id()));
- } else if (app == extension2_->id()) {
- result += "app2";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension2_->id()));
- } else if (app == extension3_->id()) {
- result += "app3";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension3_->id()));
- } else if (app == extension4_->id()) {
- result += "app4";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension4_->id()));
- } else if (app == extension5_->id()) {
- result += "app5";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension5_->id()));
- } else if (app == extension6_->id()) {
- result += "app6";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension6_->id()));
- } else if (app == extension7_->id()) {
- result += "app7";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension7_->id()));
- } else if (app == extension8_->id()) {
- result += "app8";
- EXPECT_FALSE(
- launcher_controller_->IsAppPinned(extension8_->id()));
- } else {
- result += "unknown";
- }
- break;
+ EXPECT_FALSE(launcher_controller_->IsAppPinned(app));
+ if (app == extension1_->id()) {
+ result += "app1";
+ } else if (app == extension2_->id()) {
+ result += "app2";
+ } else if (app == extension3_->id()) {
+ result += "app3";
+ } else if (app == extension4_->id()) {
+ result += "app4";
+ } else if (app == extension5_->id()) {
+ result += "app5";
+ } else if (app == extension6_->id()) {
+ result += "app6";
+ } else if (app == extension7_->id()) {
+ result += "app7";
+ } else if (app == extension8_->id()) {
+ result += "app8";
+ } else {
+ result += "unknown";
}
+ break;
+ }
case ash::TYPE_APP_SHORTCUT: {
const std::string& app =
launcher_controller_->GetAppIDForShelfID(model_->items()[i].id);
- if (app == extension1_->id()) {
- result += "App1";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- } else if (app == extension2_->id()) {
- result += "App2";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
- } else if (app == extension3_->id()) {
- result += "App3";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
- } else if (app == extension4_->id()) {
- result += "App4";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
- } else if (app == extension5_->id()) {
- result += "App5";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension5_->id()));
- } else if (app == extension6_->id()) {
- result += "App6";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension6_->id()));
- } else if (app == extension7_->id()) {
- result += "App7";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension7_->id()));
- } else if (app == extension8_->id()) {
- result += "App8";
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension8_->id()));
- } else if (app == arc_support_host_->id()) {
- result += "Play Store";
- EXPECT_TRUE(
- launcher_controller_->IsAppPinned(arc_support_host_->id()));
- } else {
- bool arc_app_found = false;
- for (const auto& arc_app : arc_test_.fake_apps()) {
- if (app == ArcAppTest::GetAppId(arc_app)) {
- result += arc_app.name;
- arc_app_found = true;
- break;
- }
+ EXPECT_TRUE(launcher_controller_->IsAppPinned(app));
+ if (app == extension1_->id()) {
+ result += "App1";
+ } else if (app == extension2_->id()) {
+ result += "App2";
+ } else if (app == extension3_->id()) {
+ result += "App3";
+ } else if (app == extension4_->id()) {
+ result += "App4";
+ } else if (app == extension5_->id()) {
+ result += "App5";
+ } else if (app == extension6_->id()) {
+ result += "App6";
+ } else if (app == extension7_->id()) {
+ result += "App7";
+ } else if (app == extension8_->id()) {
+ result += "App8";
+ } else if (app == arc_support_host_->id()) {
+ result += "Play Store";
+ } else {
+ bool arc_app_found = false;
+ for (const auto& arc_app : arc_test_.fake_apps()) {
+ if (app == ArcAppTest::GetAppId(arc_app)) {
+ result += arc_app.name;
+ arc_app_found = true;
+ break;
}
- if (!arc_app_found)
- result += "unknown";
}
- break;
+ if (!arc_app_found)
+ result += "unknown";
}
+ break;
+ }
case ash::TYPE_BROWSER_SHORTCUT:
result += "Chrome";
break;
@@ -1578,31 +1553,26 @@ TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) {
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_EQ(ash::kInvalidShelfID, GetShelfIDForAppID(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
+ EXPECT_EQ(ash::kInvalidShelfID, GetShelfIDForAppID(extension2_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
- EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type);
+ EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension2_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension2_->id()));
}
// Check that multiple locks of an application will be properly handled.
@@ -1611,35 +1581,29 @@ TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) {
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
for (int i = 0; i < 2; i++) {
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
- EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type);
+ EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(
- extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
}
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
- EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type);
+ EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
- EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
}
// Check that already pinned items are not effected by locks.
@@ -1648,38 +1612,34 @@ TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) {
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
- EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
launcher_controller_->PinAppWithID(extension1_->id());
- EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
Mr4D (OOO till 08-26) 2016/11/23 23:11:51 Hmmm. Why did you remove this test? After pinning
msw 2016/11/24 00:00:55 This is redundant with line 1621, right?
Mr4D (OOO till 08-26) 2016/11/24 02:21:33 Yes. There it is. Never mind.
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->UnpinAppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
+ EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
Mr4D (OOO till 08-26) 2016/11/23 23:11:51 Note: that you also test for not being pinned afte
msw 2016/11/24 00:00:55 Would you like me to add a comment here, like "Ens
Mr4D (OOO till 08-26) 2016/11/24 02:21:33 No need, that was meant for the comment above whic
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
}
// Check that already pinned items which get locked stay after unpinning.
@@ -1688,35 +1648,34 @@ TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) {
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->PinAppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->UnpinAppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
- EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type);
+ EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
+ EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
}
// Check that running applications wich are not pinned get properly restored
@@ -2281,35 +2240,34 @@ TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) {
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
- EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type);
+ EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->PinAppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
- EXPECT_FALSE(
- launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
+ EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
launcher_controller_->UnpinAppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
+ EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
+ EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id()));
}
// Check that a locked (windowed V1 application) will be properly converted

Powered by Google App Engine
This is Rietveld 408576698