OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
6 #import "testing/gtest_mac.h" | 6 #import "testing/gtest_mac.h" |
7 #import "ui/app_list/cocoa/app_list_view_controller.h" | 7 #import "ui/app_list/cocoa/app_list_view_controller.h" |
8 #import "ui/app_list/cocoa/apps_grid_controller.h" | 8 #import "ui/app_list/cocoa/apps_grid_controller.h" |
9 #import "ui/app_list/cocoa/test/apps_grid_controller_test_helper.h" | 9 #import "ui/app_list/cocoa/test/apps_grid_controller_test_helper.h" |
10 #include "ui/app_list/test/app_list_test_model.h" | 10 #include "ui/app_list/test/app_list_test_model.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 EXPECT_EQ(2, [pager segmentCount]); | 51 EXPECT_EQ(2, [pager segmentCount]); |
52 model()->PopulateApps(1); | 52 model()->PopulateApps(1); |
53 EXPECT_EQ(3, [pager segmentCount]); | 53 EXPECT_EQ(3, [pager segmentCount]); |
54 | 54 |
55 ReplaceTestModel(1); | 55 ReplaceTestModel(1); |
56 EXPECT_EQ(1, [pager segmentCount]); | 56 EXPECT_EQ(1, [pager segmentCount]); |
57 } | 57 } |
58 | 58 |
59 // Test that clicking the pager changes pages. | 59 // Test that clicking the pager changes pages. |
60 TEST_F(AppListViewControllerTest, PagerChangingPage) { | 60 TEST_F(AppListViewControllerTest, PagerChangingPage) { |
61 [AppsGridController setScrollAnimationDuration:0.0]; | |
tapted
2013/05/17 04:24:15
note: moved to AppsGridControllerTestHelper() cons
| |
62 NSSegmentedControl* pager = [app_list_view_controller_ pagerControl]; | 61 NSSegmentedControl* pager = [app_list_view_controller_ pagerControl]; |
63 ReplaceTestModel(kItemsPerPage * 3); | 62 ReplaceTestModel(kItemsPerPage * 3); |
64 EXPECT_EQ(3, [pager segmentCount]); | 63 EXPECT_EQ(3, [pager segmentCount]); |
65 | 64 |
66 EXPECT_EQ(0, [pager selectedSegment]); | 65 EXPECT_EQ(0, [pager selectedSegment]); |
67 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); | 66 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); |
68 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:0]); | 67 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:0]); |
69 EXPECT_EQ(0.0, [apps_grid_controller_ visiblePortionOfPage:1]); | 68 EXPECT_EQ(0.0, [apps_grid_controller_ visiblePortionOfPage:1]); |
70 | 69 |
71 // Emulate a click on the second segment to navigate to the second page. | 70 // Emulate a click on the second segment to navigate to the second page. |
72 [pager setSelectedSegment:1]; | 71 [pager setSelectedSegment:1]; |
73 [[pager target] performSelector:[pager action] | 72 [[pager target] performSelector:[pager action] |
74 withObject:pager]; | 73 withObject:pager]; |
75 | 74 |
76 EXPECT_EQ(1u, [apps_grid_controller_ visiblePage]); | 75 EXPECT_EQ(1u, [apps_grid_controller_ visiblePage]); |
77 EXPECT_EQ(1, [pager selectedSegment]); | 76 EXPECT_EQ(1, [pager selectedSegment]); |
78 EXPECT_EQ(0.0, [apps_grid_controller_ visiblePortionOfPage:0]); | 77 EXPECT_EQ(0.0, [apps_grid_controller_ visiblePortionOfPage:0]); |
79 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:1]); | 78 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:1]); |
80 | 79 |
81 // Replace with a single page model, and ensure we go back to the first page. | 80 // Replace with a single page model, and ensure we go back to the first page. |
82 ReplaceTestModel(1); | 81 ReplaceTestModel(1); |
83 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); | 82 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); |
84 EXPECT_EQ(0, [pager selectedSegment]); | 83 EXPECT_EQ(0, [pager selectedSegment]); |
85 EXPECT_EQ(1, [pager segmentCount]); | 84 EXPECT_EQ(1, [pager segmentCount]); |
86 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:0]); | 85 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:0]); |
87 } | 86 } |
88 | 87 |
89 } // namespace test | 88 } // namespace test |
90 } // namespace app_list | 89 } // namespace app_list |
OLD | NEW |