OLD | NEW |
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 "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/browser/net/url_fixer_upper.h" | 8 #include "chrome/browser/net/url_fixer_upper.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "chrome/test/automation/tab_proxy.h" | 11 #include "chrome/test/automation/tab_proxy.h" |
12 #include "chrome/test/automation/browser_proxy.h" | 12 #include "chrome/test/automation/browser_proxy.h" |
13 #include "chrome/test/ui/ui_test.h" | 13 #include "chrome/test/ui/ui_test.h" |
14 #include "net/url_request/url_request_unittest.h" | 14 #include "net/test/test_server.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const wchar_t kDocRoot[] = L"chrome/test/data"; | 18 const wchar_t kDocRoot[] = L"chrome/test/data"; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 typedef UITest RepostFormWarningTest; | 22 typedef UITest RepostFormWarningTest; |
23 | 23 |
24 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
25 // http://crbug.com/47228 | 25 // http://crbug.com/47228 |
26 #define MAYBE_TestDoubleReload FLAKY_TestDoubleReload | 26 #define MAYBE_TestDoubleReload FLAKY_TestDoubleReload |
27 #else | 27 #else |
28 #define MAYBE_TestDoubleReload TestDoubleReload | 28 #define MAYBE_TestDoubleReload TestDoubleReload |
29 #endif | 29 #endif |
30 | 30 |
31 TEST_F(RepostFormWarningTest, MAYBE_TestDoubleReload) { | 31 TEST_F(RepostFormWarningTest, MAYBE_TestDoubleReload) { |
32 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 32 scoped_refptr<net::HTTPTestServer> server( |
| 33 net::HTTPTestServer::CreateServer(kDocRoot)); |
33 ASSERT_TRUE(NULL != server.get()); | 34 ASSERT_TRUE(NULL != server.get()); |
34 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 35 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
35 ASSERT_TRUE(browser.get()); | 36 ASSERT_TRUE(browser.get()); |
36 | 37 |
37 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | 38 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
38 ASSERT_TRUE(tab.get()); | 39 ASSERT_TRUE(tab.get()); |
39 | 40 |
40 // Load a form. | 41 // Load a form. |
41 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("files/form.html"))); | 42 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("files/form.html"))); |
42 // Submit it. | 43 // Submit it. |
43 ASSERT_TRUE(tab->NavigateToURL(GURL( | 44 ASSERT_TRUE(tab->NavigateToURL(GURL( |
44 "javascript:document.getElementById('form').submit()"))); | 45 "javascript:document.getElementById('form').submit()"))); |
45 | 46 |
46 // Try to reload it twice, checking for repost. | 47 // Try to reload it twice, checking for repost. |
47 tab->ReloadAsync(); | 48 tab->ReloadAsync(); |
48 tab->ReloadAsync(); | 49 tab->ReloadAsync(); |
49 | 50 |
50 // Navigate away from the page (this is when the test usually crashes). | 51 // Navigate away from the page (this is when the test usually crashes). |
51 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("bar"))); | 52 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("bar"))); |
52 } | 53 } |
53 | 54 |
54 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
55 // http://crbug.com/47228 | 56 // http://crbug.com/47228 |
56 #define MAYBE_TestLoginAfterRepost FLAKY_TestLoginAfterRepost | 57 #define MAYBE_TestLoginAfterRepost FLAKY_TestLoginAfterRepost |
57 #else | 58 #else |
58 #define MAYBE_TestLoginAfterRepost TestLoginAfterRepost | 59 #define MAYBE_TestLoginAfterRepost TestLoginAfterRepost |
59 #endif | 60 #endif |
60 | 61 |
61 TEST_F(RepostFormWarningTest, MAYBE_TestLoginAfterRepost) { | 62 TEST_F(RepostFormWarningTest, MAYBE_TestLoginAfterRepost) { |
62 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 63 scoped_refptr<net::HTTPTestServer> server( |
| 64 net::HTTPTestServer::CreateServer(kDocRoot)); |
63 ASSERT_TRUE(NULL != server.get()); | 65 ASSERT_TRUE(NULL != server.get()); |
64 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 66 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
65 ASSERT_TRUE(browser.get()); | 67 ASSERT_TRUE(browser.get()); |
66 | 68 |
67 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | 69 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
68 ASSERT_TRUE(tab.get()); | 70 ASSERT_TRUE(tab.get()); |
69 | 71 |
70 // Load a form. | 72 // Load a form. |
71 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("files/form.html"))); | 73 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("files/form.html"))); |
72 // Submit it. | 74 // Submit it. |
73 ASSERT_TRUE(tab->NavigateToURL(GURL( | 75 ASSERT_TRUE(tab->NavigateToURL(GURL( |
74 "javascript:document.getElementById('form').submit()"))); | 76 "javascript:document.getElementById('form').submit()"))); |
75 | 77 |
76 // Try to reload it, checking for repost. | 78 // Try to reload it, checking for repost. |
77 tab->ReloadAsync(); | 79 tab->ReloadAsync(); |
78 | 80 |
79 // Navigate to a page that requires authentication, bringing up another | 81 // Navigate to a page that requires authentication, bringing up another |
80 // tab-modal sheet. | 82 // tab-modal sheet. |
81 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("auth-basic"))); | 83 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("auth-basic"))); |
82 | 84 |
83 // Try to reload it again. | 85 // Try to reload it again. |
84 tab->ReloadAsync(); | 86 tab->ReloadAsync(); |
85 | 87 |
86 // Navigate away from the page. | 88 // Navigate away from the page. |
87 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("bar"))); | 89 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPage("bar"))); |
88 } | 90 } |
OLD | NEW |