| Index: ash/launcher/launcher_navigator_unittest.cc
|
| diff --git a/ash/launcher/launcher_navigator_unittest.cc b/ash/launcher/launcher_navigator_unittest.cc
|
| index 60133909a71c9b8b618856570fac24191418f0d6..b8df2241c8484386e7dfa1601c93ba392227748b 100644
|
| --- a/ash/launcher/launcher_navigator_unittest.cc
|
| +++ b/ash/launcher/launcher_navigator_unittest.cc
|
| @@ -4,9 +4,11 @@
|
|
|
| #include "ash/launcher/launcher_navigator.h"
|
|
|
| +#include "ash/ash_switches.h"
|
| #include "ash/launcher/launcher.h"
|
| #include "ash/launcher/launcher_model.h"
|
| #include "ash/launcher/launcher_types.h"
|
| +#include "base/command_line.h"
|
| #include "base/compiler_specific.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -62,6 +64,21 @@ class LauncherNavigatorTest : public testing::Test {
|
| DISALLOW_COPY_AND_ASSIGN(LauncherNavigatorTest);
|
| };
|
|
|
| +class LauncherNavigatorLegacyShelfLayoutTest : public LauncherNavigatorTest {
|
| + public:
|
| + LauncherNavigatorLegacyShelfLayoutTest() : LauncherNavigatorTest() {}
|
| +
|
| + protected:
|
| + virtual void SetUp() OVERRIDE {
|
| + CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + ash::switches::kAshDisableAlternateShelfLayout);
|
| + LauncherNavigatorTest::SetUp();
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(LauncherNavigatorLegacyShelfLayoutTest);
|
| +};
|
| +
|
| } // namespace
|
|
|
| TEST_F(LauncherNavigatorTest, BasicCycle) {
|
| @@ -69,6 +86,22 @@ TEST_F(LauncherNavigatorTest, BasicCycle) {
|
| LauncherItemType types[] = {
|
| TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED,
|
| };
|
| + // LauncherModel automatically adds BROWSER_SHORTCUT and APP_LIST item at the
|
| + // beginning, so '3' refers the first TYPE_TABBED item.
|
| + SetupMockLauncherModel(types, arraysize(types), 3);
|
| +
|
| + EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
|
| +
|
| + // Fifth one. It will skip the APP_SHORTCUT and APP_LIST at the beginning
|
| + // of the list.
|
| + EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
|
| +}
|
| +
|
| +TEST_F(LauncherNavigatorLegacyShelfLayoutTest, BasicCycle) {
|
| + // An app shortcut and three windows
|
| + LauncherItemType types[] = {
|
| + TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED,
|
| + };
|
| // LauncherModel automatically adds BROWSER_SHORTCUT item at the
|
| // beginning, so '2' refers the first TYPE_TABBED item.
|
| SetupMockLauncherModel(types, arraysize(types), 2);
|
| @@ -84,6 +117,17 @@ TEST_F(LauncherNavigatorTest, WrapToBeginning) {
|
| LauncherItemType types[] = {
|
| TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED,
|
| };
|
| + SetupMockLauncherModel(types, arraysize(types), 5);
|
| +
|
| + // Second one. It wraps to the beginning, and skips APP_LIST and
|
| + // BROWSER_SHORTCUT items at the beginning of the list.
|
| + EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
|
| +}
|
| +
|
| +TEST_F(LauncherNavigatorLegacyShelfLayoutTest, WrapToBeginning) {
|
| + LauncherItemType types[] = {
|
| + TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED,
|
| + };
|
| SetupMockLauncherModel(types, arraysize(types), 4);
|
|
|
| // Second one. It skips the APP_LIST item at the end of the list,
|
| @@ -100,6 +144,16 @@ TEST_F(LauncherNavigatorTest, Empty) {
|
|
|
| TEST_F(LauncherNavigatorTest, SingleEntry) {
|
| LauncherItemType type = TYPE_TABBED;
|
| + SetupMockLauncherModel(&type, 1, 2);
|
| +
|
| + // If there's only one item there and it is already active, there's no item
|
| + // to be activated next.
|
| + EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
|
| + EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
|
| +}
|
| +
|
| +TEST_F(LauncherNavigatorLegacyShelfLayoutTest, SingleEntry) {
|
| + LauncherItemType type = TYPE_TABBED;
|
| SetupMockLauncherModel(&type, 1, 1);
|
|
|
| // If there's only one item there and it is already active, there's no item
|
| @@ -116,6 +170,18 @@ TEST_F(LauncherNavigatorTest, NoActive) {
|
| SetupMockLauncherModel(types, arraysize(types), -1);
|
|
|
| // If there are no active status, pick the first running item as a fallback.
|
| + EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
|
| + EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
|
| +}
|
| +
|
| +TEST_F(LauncherNavigatorLegacyShelfLayoutTest, NoActive) {
|
| + LauncherItemType types[] = {
|
| + TYPE_TABBED, TYPE_TABBED,
|
| + };
|
| + // Special case: no items are 'STATUS_ACTIVE'.
|
| + SetupMockLauncherModel(types, arraysize(types), -1);
|
| +
|
| + // If there are no active status, pick the first running item as a fallback.
|
| EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
|
| EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
|
| }
|
|
|