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

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

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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) 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 #if defined(OS_POSIX) 5 #if defined(OS_POSIX)
6 #include <signal.h> 6 #include <signal.h>
7 #endif 7 #endif
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/net/url_request_mock_util.h" 13 #include "chrome/browser/net/url_request_mock_util.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "components/app_modal/javascript_app_modal_dialog.h" 21 #include "components/app_modal/javascript_app_modal_dialog.h"
22 #include "components/app_modal/native_app_modal_dialog.h" 22 #include "components/app_modal/native_app_modal_dialog.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
27 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
28 #include "net/test/embedded_test_server/embedded_test_server.h"
28 #include "net/test/url_request/url_request_mock_http_job.h" 29 #include "net/test/url_request/url_request_mock_http_job.h"
29 #include "net/url_request/url_request_test_util.h" 30 #include "net/url_request/url_request_test_util.h"
30 31
31 #if defined(OS_WIN) 32 #if defined(OS_WIN)
32 // For version specific disabled tests below (http://crbug.com/267597). 33 // For version specific disabled tests below (http://crbug.com/267597).
33 #include "base/win/windows_version.h" 34 #include "base/win/windows_version.h"
34 #endif 35 #endif
35 36
36 using base::TimeDelta; 37 using base::TimeDelta;
37 using content::BrowserThread; 38 using content::BrowserThread;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 423 }
423 424
424 class FastUnloadTest : public UnloadTest { 425 class FastUnloadTest : public UnloadTest {
425 public: 426 public:
426 void SetUpCommandLine(base::CommandLine* command_line) override { 427 void SetUpCommandLine(base::CommandLine* command_line) override {
427 UnloadTest::SetUpCommandLine(command_line); 428 UnloadTest::SetUpCommandLine(command_line);
428 command_line->AppendSwitch(switches::kEnableFastUnload); 429 command_line->AppendSwitch(switches::kEnableFastUnload);
429 } 430 }
430 431
431 void SetUpInProcessBrowserTestFixture() override { 432 void SetUpInProcessBrowserTestFixture() override {
432 ASSERT_TRUE(test_server()->Start()); 433 ASSERT_TRUE(embedded_test_server()->Start());
433 } 434 }
434 435
435 void TearDownInProcessBrowserTestFixture() override { test_server()->Stop(); }
436
437 GURL GetUrl(const std::string& name) { 436 GURL GetUrl(const std::string& name) {
438 return GURL(test_server()->GetURL( 437 return GURL(
439 "files/fast_tab_close/" + name + ".html")); 438 embedded_test_server()->GetURL("/fast_tab_close/" + name + ".html"));
440 } 439 }
441 440
442 void NavigateToPage(const char* name) { 441 void NavigateToPage(const char* name) {
443 ui_test_utils::NavigateToURL(browser(), GetUrl(name)); 442 ui_test_utils::NavigateToURL(browser(), GetUrl(name));
444 CheckTitle(name); 443 CheckTitle(name);
445 } 444 }
446 445
447 void NavigateToPageInNewTab(const char* name) { 446 void NavigateToPageInNewTab(const char* name) {
448 ui_test_utils::NavigateToURLWithDisposition( 447 ui_test_utils::NavigateToURLWithDisposition(
449 browser(), GetUrl(name), NEW_FOREGROUND_TAB, 448 browser(), GetUrl(name), NEW_FOREGROUND_TAB,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 content::WindowedNotificationObserver window_observer( 637 content::WindowedNotificationObserver window_observer(
639 chrome::NOTIFICATION_BROWSER_CLOSED, 638 chrome::NOTIFICATION_BROWSER_CLOSED,
640 content::NotificationService::AllSources()); 639 content::NotificationService::AllSources());
641 chrome::CloseWindow(browser()); 640 chrome::CloseWindow(browser());
642 CrashTab(beforeunload_contents); 641 CrashTab(beforeunload_contents);
643 window_observer.Wait(); 642 window_observer.Wait();
644 } 643 }
645 644
646 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs 645 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs
647 // and multiple windows. 646 // and multiple windows.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698