OLD | NEW |
---|---|
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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/javascript_browser_test.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
15 #include "net/test/spawned_test_server/spawned_test_server.h" | 15 #include "net/test/spawned_test_server/spawned_test_server.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 class FtpBrowserTest : public InProcessBrowserTest { | 19 class FtpBrowserTest : public JavaScriptBrowserTest { |
20 public: | 20 public: |
21 FtpBrowserTest() | 21 FtpBrowserTest() |
22 : ftp_server_(net::SpawnedTestServer::TYPE_FTP, | 22 : ftp_server_(net::SpawnedTestServer::TYPE_FTP, |
23 net::SpawnedTestServer::kLocalhost, | 23 net::SpawnedTestServer::kLocalhost, |
24 base::FilePath(FILE_PATH_LITERAL("chrome/test/data/ftp"))) { | 24 base::FilePath(FILE_PATH_LITERAL("chrome/test/data/ftp"))) { |
25 } | 25 } |
26 | 26 |
27 void TearDownOnMainThread() override { | |
28 // TODO(dbeam): should all JavaScriptBrowserTests do something like this? | |
29 if (has_console_info()) { | |
30 FAIL(); | |
mmenke
2016/06/03 16:05:51
ADD_FAILURE()? The FAIL macro includes a return s
Dan Beam
2016/06/03 18:58:27
Done.
| |
31 set_has_console_info(false); | |
32 } | |
33 JavaScriptBrowserTest::TearDownOnMainThread(); | |
34 } | |
35 | |
27 protected: | 36 protected: |
28 net::SpawnedTestServer ftp_server_; | 37 net::SpawnedTestServer ftp_server_; |
29 }; | 38 }; |
30 | 39 |
31 void WaitForTitle(content::WebContents* contents, const char* expected_title) { | 40 void WaitForTitle(content::WebContents* contents, const char* expected_title) { |
32 content::TitleWatcher title_watcher(contents, | 41 content::TitleWatcher title_watcher(contents, |
33 base::ASCIIToUTF16(expected_title)); | 42 base::ASCIIToUTF16(expected_title)); |
34 | 43 |
35 EXPECT_EQ(base::ASCIIToUTF16(expected_title), | 44 EXPECT_EQ(base::ASCIIToUTF16(expected_title), |
36 title_watcher.WaitAndGetTitle()); | 45 title_watcher.WaitAndGetTitle()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 "var elements = document.getElementsByTagName('a');" | 87 "var elements = document.getElementsByTagName('a');" |
79 "for (var i = 0; i < elements.length; i++) {" | 88 "for (var i = 0; i < elements.length; i++) {" |
80 " if (elements[i].innerHTML == 'test.html') {" | 89 " if (elements[i].innerHTML == 'test.html') {" |
81 " elements[i].click();" | 90 " elements[i].click();" |
82 " }" | 91 " }" |
83 "}")); | 92 "}")); |
84 | 93 |
85 WaitForTitle(browser()->tab_strip_model()->GetActiveWebContents(), | 94 WaitForTitle(browser()->tab_strip_model()->GetActiveWebContents(), |
86 "PASS"); | 95 "PASS"); |
87 } | 96 } |
OLD | NEW |