| Index: ash/launcher/launcher_model_unittest.cc
|
| diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc
|
| index 7011e2708b65e17a0636fcbcb4f29496b5a7d39a..38a855b02a61d354363fed0e8c3866ed92bebb15 100644
|
| --- a/ash/launcher/launcher_model_unittest.cc
|
| +++ b/ash/launcher/launcher_model_unittest.cc
|
| @@ -7,7 +7,9 @@
|
| #include <set>
|
| #include <string>
|
|
|
| +#include "ash/ash_switches.h"
|
| #include "ash/launcher/launcher_model_observer.h"
|
| +#include "base/command_line.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -143,6 +145,94 @@ TEST(LauncherModel, AddIndices) {
|
| LauncherItem browser_shortcut;
|
| browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
|
| int browser_shortcut_index = model.Add(browser_shortcut);
|
| + EXPECT_EQ(1, browser_shortcut_index);
|
| +
|
| + // platform app items should be after browser shortcut.
|
| + LauncherItem item;
|
| + item.type = TYPE_PLATFORM_APP;
|
| + int platform_app_index1 = model.Add(item);
|
| + EXPECT_EQ(2, platform_app_index1);
|
| +
|
| + // Add another platform app item, it should follow first.
|
| + int platform_app_index2 = model.Add(item);
|
| + EXPECT_EQ(3, platform_app_index2);
|
| +
|
| + // APP_SHORTCUT priority is higher than PLATFORM_APP but same as
|
| + // BROWSER_SHORTCUT. So APP_SHORTCUT is located after BROWSER_SHORCUT.
|
| + item.type = TYPE_APP_SHORTCUT;
|
| + int app_shortcut_index1 = model.Add(item);
|
| + EXPECT_EQ(2, app_shortcut_index1);
|
| +
|
| + item.type = TYPE_APP_SHORTCUT;
|
| + int app_shortcut_index2 = model.Add(item);
|
| + EXPECT_EQ(3, app_shortcut_index2);
|
| +
|
| + // Check that AddAt() figures out the correct indexes for app shortcuts.
|
| + // APP_SHORTCUT and BROWSER_SHORTCUT has the same weight.
|
| + // So APP_SHORTCUT is located at index 0. And, BROWSER_SHORTCUT is located at
|
| + // index 1.
|
| + item.type = TYPE_APP_SHORTCUT;
|
| + int app_shortcut_index3 = model.AddAt(1, item);
|
| + EXPECT_EQ(1, app_shortcut_index3);
|
| +
|
| + item.type = TYPE_APP_SHORTCUT;
|
| + int app_shortcut_index4 = model.AddAt(6, item);
|
| + EXPECT_EQ(5, app_shortcut_index4);
|
| +
|
| + item.type = TYPE_APP_SHORTCUT;
|
| + int app_shortcut_index5 = model.AddAt(3, item);
|
| + EXPECT_EQ(3, app_shortcut_index5);
|
| +
|
| + // Before there are any panels, no icons should be right aligned.
|
| + EXPECT_EQ(model.item_count(), model.FirstPanelIndex());
|
| +
|
| + // Check that AddAt() figures out the correct indexes for platform apps and
|
| + // panels.
|
| + item.type = TYPE_PLATFORM_APP;
|
| + int platform_app_index3 = model.AddAt(3, item);
|
| + EXPECT_EQ(7, platform_app_index3);
|
| +
|
| + item.type = TYPE_APP_PANEL;
|
| + int app_panel_index1 = model.AddAt(2, item);
|
| + EXPECT_EQ(10, app_panel_index1);
|
| +
|
| + item.type = TYPE_PLATFORM_APP;
|
| + int platform_app_index4 = model.AddAt(11, item);
|
| + EXPECT_EQ(10, platform_app_index4);
|
| +
|
| + item.type = TYPE_APP_PANEL;
|
| + int app_panel_index2 = model.AddAt(12, item);
|
| + EXPECT_EQ(12, app_panel_index2);
|
| +
|
| + item.type = TYPE_PLATFORM_APP;
|
| + int platform_app_index5 = model.AddAt(7, item);
|
| + EXPECT_EQ(7, platform_app_index5);
|
| +
|
| + item.type = TYPE_APP_PANEL;
|
| + int app_panel_index3 = model.AddAt(13, item);
|
| + EXPECT_EQ(13, app_panel_index3);
|
| +
|
| + // Right aligned index should be the first app panel index.
|
| + EXPECT_EQ(12, model.FirstPanelIndex());
|
| +
|
| + EXPECT_EQ(TYPE_BROWSER_SHORTCUT, model.items()[2].type);
|
| + EXPECT_EQ(TYPE_APP_LIST, model.items()[0].type);
|
| +}
|
| +
|
| +// Assertions around where items are added.
|
| +TEST(LauncherModel, AddIndicesForLegacyShelfLayout) {
|
| + CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + ash::switches::kAshDisableAlternateShelfLayout);
|
| + TestLauncherModelObserver observer;
|
| + LauncherModel model;
|
| +
|
| + // Model is initially populated with one item.
|
| + EXPECT_EQ(1, model.item_count());
|
| +
|
| + // Insert browser short cut at index 0.
|
| + LauncherItem browser_shortcut;
|
| + browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
|
| + int browser_shortcut_index = model.Add(browser_shortcut);
|
| EXPECT_EQ(0, browser_shortcut_index);
|
|
|
| // platform app items should be after browser shortcut.
|
| @@ -155,7 +245,7 @@ TEST(LauncherModel, AddIndices) {
|
| int platform_app_index2 = model.Add(item);
|
| EXPECT_EQ(2, platform_app_index2);
|
|
|
| - // APP_SHORTCUT's priority is higher than PLATFORM_APP but same as
|
| + // APP_SHORTCUT priority is higher than PLATFORM_APP but same as
|
| // BROWSER_SHORTCUT. So APP_SHORTCUT is located after BROWSER_SHORCUT.
|
| item.type = TYPE_APP_SHORTCUT;
|
| int app_shortcut_index1 = model.Add(item);
|
| @@ -258,6 +348,39 @@ TEST(LauncherModel, CorrectMoveItemsWhenStateChange) {
|
| LauncherItem browser_shortcut;
|
| browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
|
| int browser_shortcut_index = model.Add(browser_shortcut);
|
| + EXPECT_EQ(1, browser_shortcut_index);
|
| +
|
| + // Add three shortcuts. They should all be moved between the two.
|
| + LauncherItem item;
|
| + item.type = TYPE_APP_SHORTCUT;
|
| + int app1_index = model.Add(item);
|
| + EXPECT_EQ(2, app1_index);
|
| + int app2_index = model.Add(item);
|
| + EXPECT_EQ(3, app2_index);
|
| + int app3_index = model.Add(item);
|
| + EXPECT_EQ(4, app3_index);
|
| +
|
| + // Now change the type of the second item and make sure that it is moving
|
| + // behind the shortcuts.
|
| + item.type = TYPE_PLATFORM_APP;
|
| + model.Set(app2_index, item);
|
| +
|
| + // The item should have moved in front of the app launcher.
|
| + EXPECT_EQ(TYPE_PLATFORM_APP, model.items()[4].type);
|
| +}
|
| +
|
| +TEST(LauncherModel, CorrectMoveItemsWhenStateChangeForLegacyShelfLayout) {
|
| + CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + ash::switches::kAshDisableAlternateShelfLayout);
|
| + LauncherModel model;
|
| +
|
| + // The app list should be the last item in the list.
|
| + EXPECT_EQ(1, model.item_count());
|
| +
|
| + // The first item is the browser.
|
| + LauncherItem browser_shortcut;
|
| + browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
|
| + int browser_shortcut_index = model.Add(browser_shortcut);
|
| EXPECT_EQ(0, browser_shortcut_index);
|
|
|
| // Add three shortcuts. They should all be moved between the two.
|
|
|