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

Side by Side Diff: ui/app_list/cocoa/app_list_view_controller_unittest.mm

Issue 22268009: Move signin status and current user information into AppListModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nit Created 7 years, 4 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 unified diff | Download patch
OLDNEW
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/mac/scoped_nsobject.h" 5 #include "base/mac/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/signin_delegate.h" 10 #include "ui/app_list/signin_delegate.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return base::string16(); 60 return base::string16();
61 } 61 }
62 62
63 protected: 63 protected:
64 base::scoped_nsobject<AppListViewController> app_list_view_controller_; 64 base::scoped_nsobject<AppListViewController> app_list_view_controller_;
65 65
66 private: 66 private:
67 DISALLOW_COPY_AND_ASSIGN(AppListViewControllerTest); 67 DISALLOW_COPY_AND_ASSIGN(AppListViewControllerTest);
68 }; 68 };
69 69
70 // Helper class allowing NeedSignin() to return true during SetUp(), to test an
71 // initial state where signin is required, and the regular view starts hidden.
72 class AppListViewControllerSigninTest : public AppListViewControllerTest {
73 public:
74 AppListViewControllerSigninTest() : needs_signin_(true) {}
75
76 // SigninDelegate override:
77 virtual bool NeedSignin() OVERRIDE { return needs_signin_; }
78
79 protected:
80 bool needs_signin_;
81
82 private:
83 DISALLOW_COPY_AND_ASSIGN(AppListViewControllerSigninTest);
84 };
85
86 TEST_VIEW(AppListViewControllerTest, [app_list_view_controller_ view]); 70 TEST_VIEW(AppListViewControllerTest, [app_list_view_controller_ view]);
87 71
88 // Test that adding and removing pages updates the pager. 72 // Test that adding and removing pages updates the pager.
89 TEST_F(AppListViewControllerTest, PagerSegmentCounts) { 73 TEST_F(AppListViewControllerTest, PagerSegmentCounts) {
90 NSSegmentedControl* pager = [app_list_view_controller_ pagerControl]; 74 NSSegmentedControl* pager = [app_list_view_controller_ pagerControl];
91 EXPECT_EQ(1, [pager segmentCount]); 75 EXPECT_EQ(1, [pager segmentCount]);
92 76
93 ReplaceTestModel(kItemsPerPage * 2); 77 ReplaceTestModel(kItemsPerPage * 2);
94 EXPECT_EQ(2, [pager segmentCount]); 78 EXPECT_EQ(2, [pager segmentCount]);
95 model()->PopulateApps(1); 79 model()->PopulateApps(1);
(...skipping 27 matching lines...) Expand all
123 // Replace with a single page model, and ensure we go back to the first page. 107 // Replace with a single page model, and ensure we go back to the first page.
124 ReplaceTestModel(1); 108 ReplaceTestModel(1);
125 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); 109 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]);
126 EXPECT_EQ(0, [pager selectedSegment]); 110 EXPECT_EQ(0, [pager selectedSegment]);
127 EXPECT_EQ(1, [pager segmentCount]); 111 EXPECT_EQ(1, [pager segmentCount]);
128 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:0]); 112 EXPECT_EQ(1.0, [apps_grid_controller_ visiblePortionOfPage:0]);
129 } 113 }
130 114
131 // Test the view when the user is already signed in. 115 // Test the view when the user is already signed in.
132 TEST_F(AppListViewControllerTest, SignedIn) { 116 TEST_F(AppListViewControllerTest, SignedIn) {
117 scoped_ptr<AppListModel> model(new AppListModel);
118 model->SetSignedIn(true);
tapted 2013/08/16 05:09:14 I think this needs to be the default. Otherwise, t
calamity 2013/08/16 07:24:05 Done.
119 ResetModel(model.Pass());
133 // There should be just 1, visible subview when signed in. 120 // There should be just 1, visible subview when signed in.
134 EXPECT_EQ(1u, [[[app_list_view_controller_ view] subviews] count]); 121 EXPECT_EQ(1u, [[[app_list_view_controller_ view] subviews] count]);
135 EXPECT_FALSE([[app_list_view_controller_ backgroundView] isHidden]); 122 EXPECT_FALSE([[app_list_view_controller_ backgroundView] isHidden]);
136 } 123 }
137 124
138 // Test the view when signin is required. 125 // Test the view when signin is required.
139 TEST_F(AppListViewControllerSigninTest, NeedsSignin) { 126 TEST_F(AppListViewControllerTest, NeedsSignin) {
140 EXPECT_EQ(2u, [[[app_list_view_controller_ view] subviews] count]); 127 EXPECT_EQ(2u, [[[app_list_view_controller_ view] subviews] count]);
141 EXPECT_TRUE([[app_list_view_controller_ backgroundView] isHidden]); 128 EXPECT_TRUE([[app_list_view_controller_ backgroundView] isHidden]);
142 129
143 // Simulate signing in, should enter the SignedIn state. 130 // Simulate signing in, should enter the SignedIn state.
144 needs_signin_ = false; 131 model()->SetSignedIn(true);
145 NotifySigninSuccess(); 132 NotifySigninSuccess();
tapted 2013/08/16 05:09:14 Thanks to your refactoring, I think this line is n
calamity 2013/08/16 07:24:05 Done.
146 EXPECT_EQ(1u, [[[app_list_view_controller_ view] subviews] count]); 133 EXPECT_EQ(1u, [[[app_list_view_controller_ view] subviews] count]);
147 EXPECT_FALSE([[app_list_view_controller_ backgroundView] isHidden]); 134 EXPECT_FALSE([[app_list_view_controller_ backgroundView] isHidden]);
148 } 135 }
149 136
150 } // namespace test 137 } // namespace test
151 } // namespace app_list 138 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/cocoa/app_list_view_controller.mm ('k') | ui/app_list/cocoa/apps_search_box_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698