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

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

Issue 3034038: GTTF: Move more test server code from net/url_request/url_request_unittest.h (Closed)
Patch Set: hopefully final Created 10 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/tab_contents/tab_contents.h" 27 #include "chrome/browser/tab_contents/tab_contents.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/extensions/extension.h" 29 #include "chrome/common/extensions/extension.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "chrome/common/page_transition_types.h" 31 #include "chrome/common/page_transition_types.h"
32 #include "chrome/test/in_process_browser_test.h" 32 #include "chrome/test/in_process_browser_test.h"
33 #include "chrome/test/ui_test_utils.h" 33 #include "chrome/test/ui_test_utils.h"
34 #include "grit/chromium_strings.h" 34 #include "grit/chromium_strings.h"
35 #include "grit/generated_resources.h" 35 #include "grit/generated_resources.h"
36 #include "net/base/mock_host_resolver.h" 36 #include "net/base/mock_host_resolver.h"
37 #include "net/test/test_server.h"
37 38
38 namespace { 39 namespace {
39 40
40 const std::string BEFORE_UNLOAD_HTML = 41 const std::string BEFORE_UNLOAD_HTML =
41 "<html><head><title>beforeunload</title></head><body>" 42 "<html><head><title>beforeunload</title></head><body>"
42 "<script>window.onbeforeunload=function(e){return 'foo'}</script>" 43 "<script>window.onbeforeunload=function(e){return 'foo'}</script>"
43 "</body></html>"; 44 "</body></html>";
44 45
45 const std::wstring OPEN_NEW_BEFOREUNLOAD_PAGE = 46 const std::wstring OPEN_NEW_BEFOREUNLOAD_PAGE =
46 L"w=window.open(); w.onbeforeunload=function(e){return 'foo'};"; 47 L"w=window.open(); w.onbeforeunload=function(e){return 'foo'};";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 DISALLOW_COPY_AND_ASSIGN(MockTabStripModelObserver); 92 DISALLOW_COPY_AND_ASSIGN(MockTabStripModelObserver);
92 }; 93 };
93 94
94 } // namespace 95 } // namespace
95 96
96 class BrowserTest : public ExtensionBrowserTest { 97 class BrowserTest : public ExtensionBrowserTest {
97 public: 98 public:
98 // Used by phantom tab tests. Creates two tabs, pins the first and makes it 99 // Used by phantom tab tests. Creates two tabs, pins the first and makes it
99 // a phantom tab (by closing it). 100 // a phantom tab (by closing it).
100 void PhantomTabTest() { 101 void PhantomTabTest() {
101 HTTPTestServer* server = StartHTTPServer(); 102 net::HTTPTestServer* server = StartHTTPServer();
102 ASSERT_TRUE(server); 103 ASSERT_TRUE(server);
103 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 104 host_resolver()->AddRule("www.example.com", "127.0.0.1");
104 GURL url(server->TestServerPage("empty.html")); 105 GURL url(server->TestServerPage("empty.html"));
105 TabStripModel* model = browser()->tabstrip_model(); 106 TabStripModel* model = browser()->tabstrip_model();
106 107
107 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 108 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
108 109
109 Extension* extension_app = GetExtension(); 110 Extension* extension_app = GetExtension();
110 111
111 ui_test_utils::NavigateToURL(browser(), url); 112 ui_test_utils::NavigateToURL(browser(), url);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 323 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
323 FilePath(kEmptyFile))); 324 FilePath(kEmptyFile)));
324 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); 325 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme));
325 ui_test_utils::NavigateToURL(browser(), file_url); 326 ui_test_utils::NavigateToURL(browser(), file_url);
326 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 327 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
327 } 328 }
328 329
329 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttp) { 330 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttp) {
330 CommandUpdater* command_updater = browser()->command_updater(); 331 CommandUpdater* command_updater = browser()->command_updater();
331 332
332 scoped_refptr<HTTPTestServer> http_server( 333 scoped_refptr<net::HTTPTestServer> http_server(
333 HTTPTestServer::CreateServer(kDocRoot)); 334 net::HTTPTestServer::CreateServer(kDocRoot));
334 ASSERT_TRUE(NULL != http_server.get()); 335 ASSERT_TRUE(NULL != http_server.get());
335 GURL http_url(http_server->TestServerPage("")); 336 GURL http_url(http_server->TestServerPage(""));
336 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); 337 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme));
337 ui_test_utils::NavigateToURL(browser(), http_url); 338 ui_test_utils::NavigateToURL(browser(), http_url);
338 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 339 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
339 } 340 }
340 341
341 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttps) { 342 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttps) {
342 CommandUpdater* command_updater = browser()->command_updater(); 343 CommandUpdater* command_updater = browser()->command_updater();
343 344
344 scoped_refptr<HTTPSTestServer> https_server( 345 scoped_refptr<net::HTTPSTestServer> https_server(
345 HTTPSTestServer::CreateGoodServer(kDocRoot)); 346 net::HTTPSTestServer::CreateGoodServer(kDocRoot));
346 ASSERT_TRUE(NULL != https_server.get()); 347 ASSERT_TRUE(NULL != https_server.get());
347 GURL https_url(https_server->TestServerPage("/")); 348 GURL https_url(https_server->TestServerPage("/"));
348 ASSERT_TRUE(https_url.SchemeIs(chrome::kHttpsScheme)); 349 ASSERT_TRUE(https_url.SchemeIs(chrome::kHttpsScheme));
349 ui_test_utils::NavigateToURL(browser(), https_url); 350 ui_test_utils::NavigateToURL(browser(), https_url);
350 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 351 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
351 } 352 }
352 353
353 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFtp) { 354 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFtp) {
354 CommandUpdater* command_updater = browser()->command_updater(); 355 CommandUpdater* command_updater = browser()->command_updater();
355 356
356 scoped_refptr<FTPTestServer> ftp_server( 357 scoped_refptr<net::FTPTestServer> ftp_server(
357 FTPTestServer::CreateServer(kDocRoot)); 358 net::FTPTestServer::CreateServer(kDocRoot));
358 ASSERT_TRUE(NULL != ftp_server.get()); 359 ASSERT_TRUE(NULL != ftp_server.get());
359 GURL ftp_url(ftp_server->TestServerPage("")); 360 GURL ftp_url(ftp_server->TestServerPage(""));
360 ASSERT_TRUE(ftp_url.SchemeIs(chrome::kFtpScheme)); 361 ASSERT_TRUE(ftp_url.SchemeIs(chrome::kFtpScheme));
361 ui_test_utils::NavigateToURL(browser(), ftp_url); 362 ui_test_utils::NavigateToURL(browser(), ftp_url);
362 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 363 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
363 } 364 }
364 365
365 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) { 366 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) {
366 CommandUpdater* command_updater = browser()->command_updater(); 367 CommandUpdater* command_updater = browser()->command_updater();
367 368
(...skipping 13 matching lines...) Expand all
381 GURL blank_url(chrome::kAboutBlankURL); 382 GURL blank_url(chrome::kAboutBlankURL);
382 ui_test_utils::NavigateToURL(browser(), blank_url); 383 ui_test_utils::NavigateToURL(browser(), blank_url);
383 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 384 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
384 } 385 }
385 #endif // !defined(OS_MACOSX) 386 #endif // !defined(OS_MACOSX)
386 387
387 // Test RenderView correctly send back favicon url for web page that redirects 388 // Test RenderView correctly send back favicon url for web page that redirects
388 // to an anchor in javascript body.onload handler. 389 // to an anchor in javascript body.onload handler.
389 IN_PROC_BROWSER_TEST_F(BrowserTest, FaviconOfOnloadRedirectToAnchorPage) { 390 IN_PROC_BROWSER_TEST_F(BrowserTest, FaviconOfOnloadRedirectToAnchorPage) {
390 static const wchar_t kDocRoot[] = L"chrome/test/data"; 391 static const wchar_t kDocRoot[] = L"chrome/test/data";
391 scoped_refptr<HTTPTestServer> server( 392 scoped_refptr<net::HTTPTestServer> server(
392 HTTPTestServer::CreateServer(kDocRoot)); 393 net::HTTPTestServer::CreateServer(kDocRoot));
393 ASSERT_TRUE(NULL != server.get()); 394 ASSERT_TRUE(NULL != server.get());
394 GURL url(server->TestServerPage("files/onload_redirect_to_anchor.html")); 395 GURL url(server->TestServerPage("files/onload_redirect_to_anchor.html"));
395 GURL expected_favicon_url(server->TestServerPage("files/test.png")); 396 GURL expected_favicon_url(server->TestServerPage("files/test.png"));
396 397
397 ui_test_utils::NavigateToURL(browser(), url); 398 ui_test_utils::NavigateToURL(browser(), url);
398 399
399 NavigationEntry* entry = browser()->GetSelectedTabContents()-> 400 NavigationEntry* entry = browser()->GetSelectedTabContents()->
400 controller().GetActiveEntry(); 401 controller().GetActiveEntry();
401 EXPECT_EQ(expected_favicon_url.spec(), entry->favicon().url().spec()); 402 EXPECT_EQ(expected_favicon_url.spec(), entry->favicon().url().spec());
402 } 403 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 446
446 // There should still be two tabs. 447 // There should still be two tabs.
447 ASSERT_EQ(2, browser()->tab_count()); 448 ASSERT_EQ(2, browser()->tab_count());
448 // The first tab should no longer be a phantom. 449 // The first tab should no longer be a phantom.
449 EXPECT_FALSE(model->IsPhantomTab(0)); 450 EXPECT_FALSE(model->IsPhantomTab(0));
450 } 451 }
451 452
452 // Makes sure TabClosing is sent when uninstalling an extension that is an app 453 // Makes sure TabClosing is sent when uninstalling an extension that is an app
453 // tab. 454 // tab.
454 IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { 455 IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) {
455 HTTPTestServer* server = StartHTTPServer(); 456 net::HTTPTestServer* server = StartHTTPServer();
456 ASSERT_TRUE(server); 457 ASSERT_TRUE(server);
457 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 458 host_resolver()->AddRule("www.example.com", "127.0.0.1");
458 GURL url(server->TestServerPage("empty.html")); 459 GURL url(server->TestServerPage("empty.html"));
459 TabStripModel* model = browser()->tabstrip_model(); 460 TabStripModel* model = browser()->tabstrip_model();
460 461
461 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 462 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
462 463
463 Extension* extension_app = GetExtension(); 464 Extension* extension_app = GetExtension();
464 465
465 ui_test_utils::NavigateToURL(browser(), url); 466 ui_test_utils::NavigateToURL(browser(), url);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 503
503 #if defined(OS_WIN) 504 #if defined(OS_WIN)
504 // http://crbug.com/46198. On XP/Vista, the failure rate is 5 ~ 6%. 505 // http://crbug.com/46198. On XP/Vista, the failure rate is 5 ~ 6%.
505 #define MAYBE_PageLanguageDetection FLAKY_PageLanguageDetection 506 #define MAYBE_PageLanguageDetection FLAKY_PageLanguageDetection
506 #else 507 #else
507 #define MAYBE_PageLanguageDetection PageLanguageDetection 508 #define MAYBE_PageLanguageDetection PageLanguageDetection
508 #endif 509 #endif
509 // Tests that the CLD (Compact Language Detection) works properly. 510 // Tests that the CLD (Compact Language Detection) works properly.
510 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) { 511 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) {
511 static const wchar_t kDocRoot[] = L"chrome/test/data"; 512 static const wchar_t kDocRoot[] = L"chrome/test/data";
512 scoped_refptr<HTTPTestServer> server( 513 scoped_refptr<net::HTTPTestServer> server(
513 HTTPTestServer::CreateServer(kDocRoot)); 514 net::HTTPTestServer::CreateServer(kDocRoot));
514 ASSERT_TRUE(NULL != server.get()); 515 ASSERT_TRUE(NULL != server.get());
515 516
516 TabContents* current_tab = browser()->GetSelectedTabContents(); 517 TabContents* current_tab = browser()->GetSelectedTabContents();
517 518
518 // Navigate to a page in English. 519 // Navigate to a page in English.
519 ui_test_utils::WindowedNotificationObserverWithDetails<TabContents, 520 ui_test_utils::WindowedNotificationObserverWithDetails<TabContents,
520 std::string> 521 std::string>
521 en_language_detected_signal(NotificationType::TAB_LANGUAGE_DETERMINED, 522 en_language_detected_signal(NotificationType::TAB_LANGUAGE_DETERMINED,
522 current_tab); 523 current_tab);
523 ui_test_utils::NavigateToURL( 524 ui_test_utils::NavigateToURL(
(...skipping 22 matching lines...) Expand all
546 547
547 // Chromeos defaults to restoring the last session, so this test isn't 548 // Chromeos defaults to restoring the last session, so this test isn't
548 // applicable. 549 // applicable.
549 #if !defined(OS_CHROMEOS) 550 #if !defined(OS_CHROMEOS)
550 #if defined(OS_MACOSX) 551 #if defined(OS_MACOSX)
551 // Crashy, http://crbug.com/38522 552 // Crashy, http://crbug.com/38522
552 #define RestorePinnedTabs DISABLED_RestorePinnedTabs 553 #define RestorePinnedTabs DISABLED_RestorePinnedTabs
553 #endif 554 #endif
554 // Makes sure pinned tabs are restored correctly on start. 555 // Makes sure pinned tabs are restored correctly on start.
555 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { 556 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) {
556 HTTPTestServer* server = StartHTTPServer(); 557 net::HTTPTestServer* server = StartHTTPServer();
557 ASSERT_TRUE(server); 558 ASSERT_TRUE(server);
558 559
559 // Add an pinned app tab. 560 // Add an pinned app tab.
560 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 561 host_resolver()->AddRule("www.example.com", "127.0.0.1");
561 GURL url(server->TestServerPage("empty.html")); 562 GURL url(server->TestServerPage("empty.html"));
562 TabStripModel* model = browser()->tabstrip_model(); 563 TabStripModel* model = browser()->tabstrip_model();
563 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 564 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
564 Extension* extension_app = GetExtension(); 565 Extension* extension_app = GetExtension();
565 ui_test_utils::NavigateToURL(browser(), url); 566 ui_test_utils::NavigateToURL(browser(), url);
566 TabContents* app_contents = new TabContents(browser()->profile(), NULL, 567 TabContents* app_contents = new TabContents(browser()->profile(), NULL,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 return false; 663 return false;
663 } 664 }
664 ui_test_utils::WaitForNavigation(&(tab->controller())); 665 ui_test_utils::WaitForNavigation(&(tab->controller()));
665 if (tab != browser()->GetSelectedTabContents()) { 666 if (tab != browser()->GetSelectedTabContents()) {
666 LOG(ERROR) << "Tab was not selected."; 667 LOG(ERROR) << "Tab was not selected.";
667 return false; 668 return false;
668 } 669 }
669 return true; 670 return true;
670 } 671 }
671 672
672 HTTPTestServer* server_; 673 net::HTTPTestServer* server_;
673 Extension* extension_app_; 674 Extension* extension_app_;
674 Profile* profile_; 675 Profile* profile_;
675 }; 676 };
676 677
677 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) 678 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS))
678 679
679 #define MAYBE_OpenTab OpenTab 680 #define MAYBE_OpenTab OpenTab
680 #define MAYBE_OpenPanel OpenPanel 681 #define MAYBE_OpenPanel OpenPanel
681 #define MAYBE_OpenWindow OpenWindow 682 #define MAYBE_OpenWindow OpenWindow
682 #define MAYBE_WindowBeforeTab WindowBeforeTab 683 #define MAYBE_WindowBeforeTab WindowBeforeTab
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 983
983 // The normal browser should now have four. 984 // The normal browser should now have four.
984 EXPECT_EQ(4, browser()->tab_count()); 985 EXPECT_EQ(4, browser()->tab_count());
985 986
986 // Close the additional browsers. 987 // Close the additional browsers.
987 popup_browser->CloseAllTabs(); 988 popup_browser->CloseAllTabs();
988 app_browser->CloseAllTabs(); 989 app_browser->CloseAllTabs();
989 app_popup_browser->CloseAllTabs(); 990 app_popup_browser->CloseAllTabs();
990 } 991 }
991 #endif 992 #endif
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_browsertest.cc ('k') | chrome/browser/browser_focus_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698