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

Unified Diff: ash/launcher/launcher_unittest.cc

Issue 9702072: Second try for (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months 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
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/wm/activation_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/launcher/launcher_unittest.cc
diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc
index 86b2af528cdaf6364f615721c8010dda495c8708..dbb0c1211eea937c49a769d52e7a90c513b7cf9f 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
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/wm/activation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698