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

Unified Diff: ash/launcher/launcher_unittest.cc

Issue 23449033: [ash] Remove Launcher::GetLauncherViewForTest() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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_tooltip_manager_unittest.cc ('k') | ash/launcher/launcher_view_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 688a29ac28bbf422e99a804922b62fa3156a9145..a572c7187e36716d58f463483c2e9ccf3c1b2fd3 100644
--- a/ash/launcher/launcher_unittest.cc
+++ b/ash/launcher/launcher_unittest.cc
@@ -10,6 +10,7 @@
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
+#include "ash/test/launcher_test_api.h"
#include "ash/test/launcher_view_test_api.h"
#include "ash/wm/window_util.h"
#include "ui/aura/root_window.h"
@@ -29,90 +30,119 @@ using ash::internal::LauncherButton;
namespace ash {
+class LauncherTest : public ash::test::AshTestBase {
+ public:
+ LauncherTest() {}
+ virtual ~LauncherTest() {}
+
+ virtual void SetUp() {
+ test::AshTestBase::SetUp();
+
+ launcher_ = Launcher::ForPrimaryDisplay();
+ ASSERT_TRUE(launcher_);
+
+ ash::test::LauncherTestAPI test(launcher_);
+ launcher_view_ = test.launcher_view();
+ launcher_model_ = launcher_view_->model();
+
+ test_.reset(new ash::test::LauncherViewTestAPI(launcher_view_));
+ }
+
+ virtual void TearDown() OVERRIDE {
+ test::AshTestBase::TearDown();
+ }
+
+ Launcher* launcher() {
+ return launcher_;
+ }
+
+ LauncherView* launcher_view() {
+ return launcher_view_;
+ }
+
+ LauncherModel* launcher_model() {
+ return launcher_model_;
+ }
+
+ ash::test::LauncherViewTestAPI* test_api() {
+ return test_.get();
+ }
+
+ private:
+ Launcher* launcher_;
sky 2013/09/13 17:12:25 member initialize these to NULL.
simonhong_ 2013/09/13 17:21:48 Done.
+ LauncherView* launcher_view_;
+ LauncherModel* launcher_model_;
+ scoped_ptr<ash::test::LauncherViewTestAPI> test_;
+
+ DISALLOW_COPY_AND_ASSIGN(LauncherTest);
+};
+
// Confirms that LauncherItem reflects the appropriated state.
TEST_F(LauncherTest, StatusReflection) {
- Launcher* launcher = Launcher::ForPrimaryDisplay();
- ASSERT_TRUE(launcher);
- LauncherView* launcher_view = launcher->GetLauncherViewForTest();
- test::LauncherViewTestAPI test(launcher_view);
- LauncherModel* model = launcher_view->model();
-
- // Initially we have the app list and chrome icon.
- int button_count = test.GetButtonCount();
+ // Initially we have the app list.
+ int button_count = test_api()->GetButtonCount();
// Add running platform app.
LauncherItem item;
item.type = TYPE_PLATFORM_APP;
item.status = STATUS_RUNNING;
- int index = model->Add(item);
- ASSERT_EQ(++button_count, test.GetButtonCount());
- LauncherButton* button = test.GetButton(index);
+ int index = launcher_model()->Add(item);
+ ASSERT_EQ(++button_count, test_api()->GetButtonCount());
+ LauncherButton* button = test_api()->GetButton(index);
EXPECT_EQ(LauncherButton::STATE_RUNNING, button->state());
// Remove it.
- model->RemoveItemAt(index);
- ASSERT_EQ(--button_count, test.GetButtonCount());
+ launcher_model()->RemoveItemAt(index);
+ ASSERT_EQ(--button_count, test_api()->GetButtonCount());
}
// Confirm that using the menu will clear the hover attribute. To avoid another
// browser test we check this here.
TEST_F(LauncherTest, checkHoverAfterMenu) {
- Launcher* launcher = Launcher::ForPrimaryDisplay();
- ASSERT_TRUE(launcher);
- LauncherView* launcher_view = launcher->GetLauncherViewForTest();
- test::LauncherViewTestAPI test(launcher_view);
- LauncherModel* model = launcher_view->model();
-
- // Initially we have the app list and chrome icon.
- int button_count = test.GetButtonCount();
+ // Initially we have the app list.
+ int button_count = test_api()->GetButtonCount();
// Add running platform app.
LauncherItem item;
item.type = TYPE_PLATFORM_APP;
item.status = STATUS_RUNNING;
- int index = model->Add(item);
- ASSERT_EQ(++button_count, test.GetButtonCount());
- LauncherButton* button = test.GetButton(index);
+ int index = launcher_model()->Add(item);
+ ASSERT_EQ(++button_count, test_api()->GetButtonCount());
+ LauncherButton* button = test_api()->GetButton(index);
button->AddState(LauncherButton::STATE_HOVERED);
button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
EXPECT_FALSE(button->state() & LauncherButton::STATE_HOVERED);
// Remove it.
- model->RemoveItemAt(index);
+ launcher_model()->RemoveItemAt(index);
}
TEST_F(LauncherTest, ShowOverflowBubble) {
- Launcher* launcher = Launcher::ForPrimaryDisplay();
- ASSERT_TRUE(launcher);
-
- LauncherView* launcher_view = launcher->GetLauncherViewForTest();
- test::LauncherViewTestAPI test(launcher_view);
-
- LauncherModel* model = launcher_view->model();
- LauncherID first_item_id = model->next_id();
+ LauncherID first_item_id = launcher_model()->next_id();
// Add platform app button until overflow.
int items_added = 0;
- while (!test.IsOverflowButtonVisible()) {
+ while (!test_api()->IsOverflowButtonVisible()) {
LauncherItem item;
item.type = TYPE_PLATFORM_APP;
item.status = STATUS_RUNNING;
- model->Add(item);
+ launcher_model()->Add(item);
++items_added;
ASSERT_LT(items_added, 10000);
}
// Shows overflow bubble.
- test.ShowOverflowBubble();
- EXPECT_TRUE(launcher->IsShowingOverflowBubble());
+ test_api()->ShowOverflowBubble();
+ EXPECT_TRUE(launcher()->IsShowingOverflowBubble());
// Removes the first item in main launcher view.
- model->RemoveItemAt(model->ItemIndexByID(first_item_id));
+ launcher_model()->RemoveItemAt(
+ launcher_model()->ItemIndexByID(first_item_id));
// Waits for all transitions to finish and there should be no crash.
- test.RunMessageLoopUntilAnimationsDone();
- EXPECT_FALSE(launcher->IsShowingOverflowBubble());
+ test_api()->RunMessageLoopUntilAnimationsDone();
+ EXPECT_FALSE(launcher()->IsShowingOverflowBubble());
}
} // namespace ash
« no previous file with comments | « ash/launcher/launcher_tooltip_manager_unittest.cc ('k') | ash/launcher/launcher_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698