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

Unified Diff: ui/app_list/cocoa/app_list_view_controller_unittest.mm

Issue 12701022: wrongbaseurl OSX App List Pager and root view controller. (Closed) Base URL: http://git.chromium.org/chromium/src.git@20130304-crbug-138633-osx-app-list-demo-polish-macbook
Patch Set: delegate should be owned by viewcontroller, test coverage Created 7 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 | « ui/app_list/cocoa/app_list_view_controller.mm ('k') | ui/app_list/cocoa/app_list_window_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/cocoa/app_list_view_controller_unittest.mm
diff --git a/ui/app_list/cocoa/app_list_view_controller_unittest.mm b/ui/app_list/cocoa/app_list_view_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d7371c4dd4fbb677c9fed89d0edd60b82d461e25
--- /dev/null
+++ b/ui/app_list/cocoa/app_list_view_controller_unittest.mm
@@ -0,0 +1,83 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/scoped_nsobject.h"
+#import "testing/gtest_mac.h"
+#import "ui/app_list/cocoa/app_list_view_controller.h"
+#import "ui/app_list/cocoa/apps_grid_controller.h"
+#import "ui/app_list/cocoa/test/apps_grid_controller_test_helper.h"
+#include "ui/app_list/test/app_list_test_model.h"
+#include "ui/app_list/test/app_list_test_view_delegate.h"
+
+namespace app_list {
+namespace test {
+
+class AppListViewControllerTest : public AppsGridControllerTestHelper {
+ public:
+ AppListViewControllerTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ app_list_view_controller_.reset([[AppListViewController alloc] init]);
+ [app_list_view_controller_ setDelegate:
+ delegate_.PassAs<AppListViewDelegate>()];
+ AppsGridControllerTestHelper::SetUpWithGridController(
+ [app_list_view_controller_ appsGridController]);
+
+ [[test_window() contentView] addSubview:[app_list_view_controller_ view]];
+ }
+
+ virtual void TearDown() OVERRIDE {
+ app_list_view_controller_.reset();
+ AppsGridControllerTestHelper::TearDown();
+ }
+
+ protected:
+ scoped_nsobject<AppListViewController> app_list_view_controller_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AppListViewControllerTest);
+};
+
+TEST_VIEW(AppListViewControllerTest, [app_list_view_controller_ view]);
+
+// Test that adding and removing pages updates the pager.
+TEST_F(AppListViewControllerTest, PagerSegmentCounts) {
+ NSSegmentedControl* pager = [app_list_view_controller_ pagerControl];
+ EXPECT_EQ(1, [pager segmentCount]);
+
+ ReplaceTestModel(kItemsPerPage * 2);
+ EXPECT_EQ(2, [pager segmentCount]);
+ model()->PopulateApps(1);
+ EXPECT_EQ(3, [pager segmentCount]);
+
+ ReplaceTestModel(1);
+ EXPECT_EQ(1, [pager segmentCount]);
+}
+
+// Test that clicking the pager changes pages.
+TEST_F(AppListViewControllerTest, PagerChangingPage) {
+ [AppsGridController setScrollAnimationDuration:0.0];
+ NSSegmentedControl* pager = [app_list_view_controller_ pagerControl];
+ ReplaceTestModel(kItemsPerPage * 3);
+ EXPECT_EQ(3, [pager segmentCount]);
+
+ EXPECT_EQ(0, [pager selectedSegment]);
+ EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]);
+
+ // Click in the center of the pager to navigate to the second page.
+ SimulateClick(pager);
+ SinkEvents();
+
+ EXPECT_EQ(1u, [apps_grid_controller_ visiblePage]);
+ EXPECT_EQ(1, [pager selectedSegment]);
+
+ // Replace with a single page model, and ensure we go back to the first page.
+ ReplaceTestModel(1);
+ EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]);
+ EXPECT_EQ(0, [pager selectedSegment]);
+ EXPECT_EQ(1, [pager segmentCount]);
+}
+
+} // namespace test
+} // namespace app_list
« no previous file with comments | « ui/app_list/cocoa/app_list_view_controller.mm ('k') | ui/app_list/cocoa/app_list_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698