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

Side by Side Diff: chrome/browser/browser_commands_unittest.cc

Issue 9826010: Made a ScopedMockUserManagerEnabler to simplify UserManager mocking life-cycle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/onc_network_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/app/chrome_command_ids.h" 5 #include "chrome/app/chrome_command_ids.h"
6 #include "chrome/browser/bookmarks/bookmark_model.h" 6 #include "chrome/browser/bookmarks/bookmark_model.h"
7 #include "chrome/browser/ui/browser_list.h" 7 #include "chrome/browser/ui/browser_list.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "chrome/test/base/browser_with_test_window_test.h" 9 #include "chrome/test/base/browser_with_test_window_test.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 ASSERT_EQ(4, browser()->active_index()); 175 ASSERT_EQ(4, browser()->active_index());
176 ASSERT_EQ(url2, browser()->GetSelectedWebContents()->GetURL()); 176 ASSERT_EQ(url2, browser()->GetSelectedWebContents()->GetURL());
177 } 177 }
178 178
179 // Tests IDC_SEARCH (the Search key on Chrome OS devices). 179 // Tests IDC_SEARCH (the Search key on Chrome OS devices).
180 #if defined(OS_CHROMEOS) 180 #if defined(OS_CHROMEOS)
181 181
182 namespace chromeos { 182 namespace chromeos {
183 183
184 TEST_F(BrowserCommandsTest, Search) { 184 TEST_F(BrowserCommandsTest, Search) {
185 scoped_ptr<MockUserManager> mock_user_manager(new MockUserManager()); 185 ScopedMockUserManagerEnabler mock_user_manager;
186 UserManager* old_user_manager = UserManager::Set(mock_user_manager.get()); 186 EXPECT_CALL(*mock_user_manager.user_manager(), IsLoggedInAsGuest())
187 EXPECT_CALL(*mock_user_manager, IsLoggedInAsGuest())
188 .Times(1).WillRepeatedly(::testing::Return(false)); 187 .Times(1).WillRepeatedly(::testing::Return(false));
189 188
190 // Load a non-NTP URL. 189 // Load a non-NTP URL.
191 GURL non_ntp_url("http://foo/"); 190 GURL non_ntp_url("http://foo/");
192 AddTab(browser(), non_ntp_url); 191 AddTab(browser(), non_ntp_url);
193 ASSERT_EQ(1, browser()->tab_count()); 192 ASSERT_EQ(1, browser()->tab_count());
194 EXPECT_EQ(non_ntp_url, browser()->GetSelectedWebContents()->GetURL()); 193 EXPECT_EQ(non_ntp_url, browser()->GetSelectedWebContents()->GetURL());
195 194
196 // Pressing the Search key should open a new tab containing the NTP. 195 // Pressing the Search key should open a new tab containing the NTP.
197 browser()->Search(); 196 browser()->Search();
198 ASSERT_EQ(2, browser()->tab_count()); 197 ASSERT_EQ(2, browser()->tab_count());
199 ASSERT_EQ(1, browser()->active_index()); 198 ASSERT_EQ(1, browser()->active_index());
200 GURL current_url = browser()->GetSelectedWebContents()->GetURL(); 199 GURL current_url = browser()->GetSelectedWebContents()->GetURL();
201 EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme)); 200 EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme));
202 EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host()); 201 EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host());
203 202
204 // Pressing it a second time while the NTP is open shouldn't change anything. 203 // Pressing it a second time while the NTP is open shouldn't change anything.
205 browser()->Search(); 204 browser()->Search();
206 ASSERT_EQ(2, browser()->tab_count()); 205 ASSERT_EQ(2, browser()->tab_count());
207 ASSERT_EQ(1, browser()->active_index()); 206 ASSERT_EQ(1, browser()->active_index());
208 current_url = browser()->GetSelectedWebContents()->GetURL(); 207 current_url = browser()->GetSelectedWebContents()->GetURL();
209 EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme)); 208 EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme));
210 EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host()); 209 EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host());
211
212 UserManager::Set(old_user_manager);
213 } 210 }
214 211
215 } // namespace chromeos 212 } // namespace chromeos
216 #endif 213 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/onc_network_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698