diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 15:35:36 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 15:35:36 +0000 |
commit | 8a08fa1fbc6c430e15af07ebec5843be6e97cb4d (patch) | |
tree | 94f004f28635d362ea09e202ec4ccedbc6025b33 /ash/launcher/launcher_unittest.cc | |
parent | b016fc8f57b48c81b2985aac394dbc71fd60396c (diff) | |
download | chromium_src-8a08fa1fbc6c430e15af07ebec5843be6e97cb4d.zip chromium_src-8a08fa1fbc6c430e15af07ebec5843be6e97cb4d.tar.gz chromium_src-8a08fa1fbc6c430e15af07ebec5843be6e97cb4d.tar.bz2 |
Second try for
https://chromiumcodereview.appspot.com/9689047/
with fix to allow for special conditions under test
BUG=115650
TEST=LauncherUpdaterTest.*
TBR=sky
Review URL: https://chromiumcodereview.appspot.com/9702072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher/launcher_unittest.cc')
-rw-r--r-- | ash/launcher/launcher_unittest.cc | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc index 86b2af5..dbb0c12 100644 --- a/ash/launcher/launcher_unittest.cc +++ b/ash/launcher/launcher_unittest.cc @@ -22,10 +22,7 @@ namespace ash { // LauncherView. TEST_F(LauncherTest, SetStatusWidth) { Launcher* launcher = Shell::GetInstance()->launcher(); - ASSERT_TRUE(launcher); - views::View* launcher_view = launcher->widget()->GetContentsView(); - ASSERT_EQ(1, launcher_view->child_count()); - launcher_view = launcher_view->child_at(0); + LauncherView* launcher_view = launcher->GetLauncherViewForTest(); int total_width = launcher->widget()->GetWindowScreenBounds().width(); ASSERT_GT(total_width, 0); @@ -33,13 +30,12 @@ TEST_F(LauncherTest, SetStatusWidth) { EXPECT_EQ(total_width - total_width / 2, launcher_view->width()); } +// Confirm that launching an app gets the appropriate state reflected in +// its button. TEST_F(LauncherTest, LaunchApp) { Launcher* launcher = Shell::GetInstance()->launcher(); ASSERT_TRUE(launcher); - views::View* contents_view = launcher->widget()->GetContentsView(); - ASSERT_EQ(1, contents_view->child_count()); - LauncherView* launcher_view = - static_cast<LauncherView*>(contents_view->child_at(0)); + LauncherView* launcher_view = launcher->GetLauncherViewForTest(); LauncherView::TestAPI test(launcher_view); LauncherModel* model = launcher->model(); @@ -72,13 +68,12 @@ TEST_F(LauncherTest, LaunchApp) { ASSERT_EQ(--button_count, test.GetButtonCount()); } +// Confirm that launching a browser gets the appropriate state reflected in +// its button. TEST_F(LauncherTest, OpenBrowser) { Launcher* launcher = Shell::GetInstance()->launcher(); ASSERT_TRUE(launcher); - views::View* contents_view = launcher->widget()->GetContentsView(); - ASSERT_EQ(1, contents_view->child_count()); - LauncherView* launcher_view = - static_cast<LauncherView*>(contents_view->child_at(0)); + LauncherView* launcher_view = launcher->GetLauncherViewForTest(); LauncherView::TestAPI test(launcher_view); LauncherModel* model = launcher->model(); @@ -100,4 +95,44 @@ TEST_F(LauncherTest, OpenBrowser) { ASSERT_EQ(--button_count, test.GetButtonCount()); } +// Confirm that opening two different browsers and changing their activation +// causes the appropriate state changes in the launcher buttons. +TEST_F(LauncherTest, OpenTwoBrowsers) { + Launcher* launcher = Shell::GetInstance()->launcher(); + ASSERT_TRUE(launcher); + LauncherView* launcher_view = launcher->GetLauncherViewForTest(); + LauncherView::TestAPI test(launcher_view); + LauncherModel* model = launcher->model(); + + // Initially we have the app list and chrome icon. + int button_count = test.GetButtonCount(); + int item_count = model->item_count(); + int button1 = button_count, button2 = button_count + 1; + int item1 = item_count; + + // Add active tab. + { + LauncherItem item; + item.type = TYPE_TABBED; + item.status = STATUS_ACTIVE; + model->Add(item_count, item); + } + ASSERT_EQ(++button_count, test.GetButtonCount()); + EXPECT_EQ(LauncherButton::STATE_ACTIVE, test.GetButton(button1)->state()); + + // Add new active tab and deactivate other. + { + LauncherItem item; + item.type = TYPE_TABBED; + model->Add(item_count, item); + LauncherItem last_item = model->items()[item1]; + last_item.status = STATUS_RUNNING; + model->Set(item1, last_item); + } + + ASSERT_EQ(++button_count, test.GetButtonCount()); + EXPECT_EQ(LauncherButton::STATE_RUNNING, test.GetButton(button1)->state()); + EXPECT_EQ(LauncherButton::STATE_ACTIVE, test.GetButton(button2)->state()); +} + } // namespace ash |