Chromium Code Reviews| Index: ash/launcher/launcher_model_unittest.cc |
| diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc |
| index c91a040b26574994efc4a32d53dfc3e16a700faa..bb7e5ebc664eb74547f0416155a227952f7462d6 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" |
| @@ -137,6 +139,91 @@ TEST(LauncherModel, AddIndices) { |
| // Model is initially populated with one item. |
| EXPECT_EQ(1, model.item_count()); |
| + // Insert browser short cut at index 1. |
| + LauncherItem browser_shortcut; |
| + browser_shortcut.type = TYPE_BROWSER_SHORTCUT; |
| + int browser_shortcut_index = model.Add(browser_shortcut); |
| + EXPECT_EQ(1, browser_shortcut_index); |
| + |
| + // Tabbed items should be after browser shortcut. |
| + LauncherItem item; |
| + int tabbed_index1 = model.Add(item); |
| + EXPECT_EQ(2, tabbed_index1); |
| + |
| + // Add another tabbed item, it should follow first. |
| + int tabbed_index2 = model.Add(item); |
| + EXPECT_EQ(3, tabbed_index2); |
| + |
| + // APP_SHORTCUT's priority is higher than TABBED but same as |
|
Mr4D (OOO till 08-26)
2013/08/27 02:35:14
Usually we use |APP_SHORTCUT| and so in comments.
Harry McCleave
2013/08/27 03:25:45
Done.
Mr4D (OOO till 08-26)
2013/08/27 14:13:36
Hmmm. Where? I still see the // APP_SHORTCUT prior
|
| + // 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 tabs and panels. |
| + item.type = TYPE_TABBED; |
| + int tabbed_index3 = model.AddAt(3, item); |
| + EXPECT_EQ(7, tabbed_index3); |
| + |
| + item.type = TYPE_APP_PANEL; |
| + int app_panel_index1 = model.AddAt(2, item); |
| + EXPECT_EQ(10, app_panel_index1); |
| + |
| + item.type = TYPE_TABBED; |
| + int tabbed_index4 = model.AddAt(11, item); |
| + EXPECT_EQ(10, tabbed_index4); |
| + |
| + item.type = TYPE_APP_PANEL; |
| + int app_panel_index2 = model.AddAt(12, item); |
| + EXPECT_EQ(12, app_panel_index2); |
| + |
| + item.type = TYPE_TABBED; |
| + int tabbed_index5 = model.AddAt(7, item); |
| + EXPECT_EQ(7, tabbed_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); |
| +} |
| + |
| +TEST(LauncherModel, TestLegacyLayoutAddIndices) { |
| + 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; |
| @@ -254,6 +341,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 to the end of the list. |
| + EXPECT_EQ(TYPE_PLATFORM_APP, model.items()[4].type); |
| +} |
| + |
| +TEST(LauncherModel, LegacyLayoutCorrectMoveItemsWhenStateChange) { |
| + 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. |