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

Side by Side Diff: chrome/browser/ui/login/login_prompt_browsertest.cc

Issue 10815025: Move TitleWatcher from ui_test_utils.h to browser_test_utils.h so it can be reused by content_brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
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 <algorithm> 5 #include <algorithm>
6 #include <list> 6 #include <list>
7 #include <map> 7 #include <map>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/prerender/prerender_manager.h" 10 #include "chrome/browser/prerender/prerender_manager.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h" 12 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/browser/ui/login/login_prompt.h" 14 #include "chrome/browser/ui/login/login_prompt.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/notification_details.h" 19 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h"
22 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
23 #include "net/base/auth.h" 24 #include "net/base/auth.h"
24 #include "net/base/mock_host_resolver.h" 25 #include "net/base/mock_host_resolver.h"
25 26
26 using content::NavigationController; 27 using content::NavigationController;
27 using content::OpenURLParams; 28 using content::OpenURLParams;
28 using content::Referrer; 29 using content::Referrer;
29 30
30 namespace { 31 namespace {
31 32
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 308 }
308 309
309 ASSERT_EQ(1u, observer.handlers_.size()); 310 ASSERT_EQ(1u, observer.handlers_.size());
310 WindowedAuthSuppliedObserver auth_supplied_waiter(controller); 311 WindowedAuthSuppliedObserver auth_supplied_waiter(controller);
311 LoginHandler* handler = *observer.handlers_.begin(); 312 LoginHandler* handler = *observer.handlers_.begin();
312 SetAuthFor(handler); 313 SetAuthFor(handler);
313 auth_supplied_waiter.Wait(); 314 auth_supplied_waiter.Wait();
314 315
315 string16 expected_title = 316 string16 expected_title =
316 ExpectedTitleFromAuth(ASCIIToUTF16("basicuser"), ASCIIToUTF16("secret")); 317 ExpectedTitleFromAuth(ASCIIToUTF16("basicuser"), ASCIIToUTF16("secret"));
317 ui_test_utils::TitleWatcher title_watcher(contents, expected_title); 318 content::TitleWatcher title_watcher(contents, expected_title);
318 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 319 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
319 } 320 }
320 321
321 // Test that "Digest" HTTP authentication works. 322 // Test that "Digest" HTTP authentication works.
322 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestDigestAuth) { 323 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestDigestAuth) {
323 ASSERT_TRUE(test_server()->Start()); 324 ASSERT_TRUE(test_server()->Start());
324 GURL test_page = test_server()->GetURL(kAuthDigestPage); 325 GURL test_page = test_server()->GetURL(kAuthDigestPage);
325 326
326 content::WebContents* contents = chrome::GetActiveWebContents(browser()); 327 content::WebContents* contents = chrome::GetActiveWebContents(browser());
327 NavigationController* controller = &contents->GetController(); 328 NavigationController* controller = &contents->GetController();
(...skipping 28 matching lines...) Expand all
356 ASSERT_EQ(1u, observer.handlers_.size()); 357 ASSERT_EQ(1u, observer.handlers_.size());
357 WindowedAuthSuppliedObserver auth_supplied_waiter(controller); 358 WindowedAuthSuppliedObserver auth_supplied_waiter(controller);
358 LoginHandler* handler = *observer.handlers_.begin(); 359 LoginHandler* handler = *observer.handlers_.begin();
359 360
360 string16 username(UTF8ToUTF16(username_digest_)); 361 string16 username(UTF8ToUTF16(username_digest_));
361 string16 password(UTF8ToUTF16(password_)); 362 string16 password(UTF8ToUTF16(password_));
362 handler->SetAuth(username, password); 363 handler->SetAuth(username, password);
363 auth_supplied_waiter.Wait(); 364 auth_supplied_waiter.Wait();
364 365
365 string16 expected_title = ExpectedTitleFromAuth(username, password); 366 string16 expected_title = ExpectedTitleFromAuth(username, password);
366 ui_test_utils::TitleWatcher title_watcher(contents, expected_title); 367 content::TitleWatcher title_watcher(contents, expected_title);
367 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 368 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
368 } 369 }
369 370
370 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestTwoAuths) { 371 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestTwoAuths) {
371 ASSERT_TRUE(test_server()->Start()); 372 ASSERT_TRUE(test_server()->Start());
372 373
373 content::WebContents* contents1 = chrome::GetActiveWebContents(browser()); 374 content::WebContents* contents1 = chrome::GetActiveWebContents(browser());
374 NavigationController* controller1 = &contents1->GetController(); 375 NavigationController* controller1 = &contents1->GetController();
375 LoginPromptBrowserTestObserver observer; 376 LoginPromptBrowserTestObserver observer;
376 377
(...skipping 29 matching lines...) Expand all
406 407
407 ASSERT_EQ(2u, observer.handlers_.size()); 408 ASSERT_EQ(2u, observer.handlers_.size());
408 409
409 LoginHandler* handler1 = *observer.handlers_.begin(); 410 LoginHandler* handler1 = *observer.handlers_.begin();
410 LoginHandler* handler2 = *(++(observer.handlers_.begin())); 411 LoginHandler* handler2 = *(++(observer.handlers_.begin()));
411 412
412 string16 expected_title1 = ExpectedTitleFromAuth( 413 string16 expected_title1 = ExpectedTitleFromAuth(
413 UTF8ToUTF16(username_basic_), UTF8ToUTF16(password_)); 414 UTF8ToUTF16(username_basic_), UTF8ToUTF16(password_));
414 string16 expected_title2 = ExpectedTitleFromAuth( 415 string16 expected_title2 = ExpectedTitleFromAuth(
415 UTF8ToUTF16(username_digest_), UTF8ToUTF16(password_)); 416 UTF8ToUTF16(username_digest_), UTF8ToUTF16(password_));
416 ui_test_utils::TitleWatcher title_watcher1(contents1, expected_title1); 417 content::TitleWatcher title_watcher1(contents1, expected_title1);
417 ui_test_utils::TitleWatcher title_watcher2(contents2, expected_title2); 418 content::TitleWatcher title_watcher2(contents2, expected_title2);
418 419
419 handler1->SetAuth(UTF8ToUTF16(username_basic_), UTF8ToUTF16(password_)); 420 handler1->SetAuth(UTF8ToUTF16(username_basic_), UTF8ToUTF16(password_));
420 handler2->SetAuth(UTF8ToUTF16(username_digest_), UTF8ToUTF16(password_)); 421 handler2->SetAuth(UTF8ToUTF16(username_digest_), UTF8ToUTF16(password_));
421 422
422 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); 423 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle());
423 EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle()); 424 EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle());
424 } 425 }
425 426
426 // Test login prompt cancellation. 427 // Test login prompt cancellation.
427 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestCancelAuth) { 428 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestCancelAuth) {
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 EXPECT_EQ(1, observer.auth_needed_count_); 1003 EXPECT_EQ(1, observer.auth_needed_count_);
1003 EXPECT_EQ(1, observer.auth_supplied_count_); 1004 EXPECT_EQ(1, observer.auth_supplied_count_);
1004 EXPECT_EQ(0, observer.auth_cancelled_count_); 1005 EXPECT_EQ(0, observer.auth_cancelled_count_);
1005 EXPECT_EQ(1, observer_incognito.auth_needed_count_); 1006 EXPECT_EQ(1, observer_incognito.auth_needed_count_);
1006 EXPECT_EQ(0, observer_incognito.auth_supplied_count_); 1007 EXPECT_EQ(0, observer_incognito.auth_supplied_count_);
1007 EXPECT_EQ(0, observer_incognito.auth_cancelled_count_); 1008 EXPECT_EQ(0, observer_incognito.auth_cancelled_count_);
1008 EXPECT_TRUE(test_server()->Stop()); 1009 EXPECT_TRUE(test_server()->Stop());
1009 } 1010 }
1010 1011
1011 } // namespace 1012 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | chrome/browser/ui/panels/old_panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698