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

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: rebase 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
133 // There should be just 1, visible subview when signed in. 117 // There should be just 1, visible subview when signed in.
134 EXPECT_EQ(1u, [[[app_list_view_controller_ view] subviews] count]); 118 EXPECT_EQ(1u, [[[app_list_view_controller_ view] subviews] count]);
135 EXPECT_FALSE([[app_list_view_controller_ backgroundView] isHidden]); 119 EXPECT_FALSE([[app_list_view_controller_ backgroundView] isHidden]);
136 } 120 }
137 121
138 // Test the view when signin is required. 122 // Test the view when signin is required.
139 TEST_F(AppListViewControllerSigninTest, NeedsSignin) { 123 TEST_F(AppListViewControllerTest, NeedsSignin) {
124 // Begin the test with a signed out app list.
125 scoped_ptr<AppListModel> new_model(new AppListModel);
126 new_model->SetSignedIn(false);
127 ResetModel(new_model.Pass());
140 EXPECT_EQ(2u, [[[app_list_view_controller_ view] subviews] count]); 128 EXPECT_EQ(2u, [[[app_list_view_controller_ view] subviews] count]);
141 EXPECT_TRUE([[app_list_view_controller_ backgroundView] isHidden]); 129 EXPECT_TRUE([[app_list_view_controller_ backgroundView] isHidden]);
142 130
143 // Simulate signing in, should enter the SignedIn state. 131 // Simulate signing in, should enter the SignedIn state.
144 needs_signin_ = false; 132 model()->SetSignedIn(true);
145 NotifySigninSuccess();
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