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 <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/content_settings/cookie_settings.h" |
8 #include "chrome/browser/net/url_fixer_upper.h" | 9 #include "chrome/browser/net/url_fixer_upper.h" |
| 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
9 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/automation/automation_proxy.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "chrome/test/automation/browser_proxy.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
12 #include "chrome/test/automation/tab_proxy.h" | |
13 #include "chrome/test/ui/ui_test.h" | |
14 #include "net/test/test_server.h" | 15 #include "net/test/test_server.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 19 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
19 | 20 |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 typedef UITest CollectedCookiesTest; | 23 typedef InProcessBrowserTest CollectedCookiesTest; |
23 | 24 |
24 // Crashing on Windows, see http://crbug.com/79331 | 25 // If this crashes on Windows, use http://crbug.com/79331 |
25 #if defined(OS_WIN) | 26 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) { |
26 #define MAYBE_DoubleDisplay DISABLED_DoubleDisplay | 27 ASSERT_TRUE(test_server()->Start()); |
27 #else | |
28 #define MAYBE_DoubleDisplay DoubleDisplay | |
29 #endif | |
30 TEST_F(CollectedCookiesTest, MAYBE_DoubleDisplay) { | |
31 net::TestServer test_server(net::TestServer::TYPE_HTTP, | |
32 net::TestServer::kLocalhost, | |
33 FilePath(kDocRoot)); | |
34 ASSERT_TRUE(test_server.Start()); | |
35 | |
36 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
37 ASSERT_TRUE(browser.get()); | |
38 | |
39 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | |
40 ASSERT_TRUE(tab.get()); | |
41 | 28 |
42 // Disable cookies. | 29 // Disable cookies. |
43 ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 30 CookieSettings::Factory::GetForProfile(browser()->profile())-> |
44 CONTENT_SETTING_BLOCK)); | 31 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); |
45 | 32 |
46 // Load a page with cookies. | 33 // Load a page with cookies. |
47 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie1.html"))); | 34 ui_test_utils::NavigateToURL( |
| 35 browser(), test_server()->GetURL("files/cookie1.html")); |
48 | 36 |
49 // Click on the info link twice. | 37 // Click on the info link twice. |
50 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); | 38 TabContentsWrapper* tab_contents = browser()->GetSelectedTabContentsWrapper(); |
51 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); | 39 browser()->ShowCollectedCookiesDialog(tab_contents); |
| 40 browser()->ShowCollectedCookiesDialog(tab_contents); |
52 } | 41 } |
53 | 42 |
54 // Crashing on Windows, see http://crbug.com/79331 | 43 // If this crashes on Windows, use http://crbug.com/79331 |
55 #if defined(OS_WIN) | 44 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) { |
56 #define MAYBE_NavigateAway DISABLED_NavigateAway | |
57 #else | |
58 #define MAYBE_NavigateAway NavigateAway | |
59 #endif | |
60 TEST_F(CollectedCookiesTest, MAYBE_NavigateAway) { | |
61 net::TestServer test_server(net::TestServer::TYPE_HTTP, | |
62 net::TestServer::kLocalhost, | |
63 FilePath(kDocRoot)); | |
64 ASSERT_TRUE(test_server.Start()); | |
65 | |
66 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
67 ASSERT_TRUE(browser.get()); | |
68 | |
69 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | |
70 ASSERT_TRUE(tab.get()); | |
71 | 45 |
72 // Disable cookies. | 46 // Disable cookies. |
73 ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 47 CookieSettings::Factory::GetForProfile(browser()->profile())-> |
74 CONTENT_SETTING_BLOCK)); | 48 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); |
75 | 49 |
76 // Load a page with cookies. | 50 // Load a page with cookies. |
77 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie1.html"))); | 51 ui_test_utils::NavigateToURL( |
| 52 browser(), test_server()->GetURL("files/cookie1.html")); |
78 | 53 |
79 // Click on the info link. | 54 // Click on the info link. |
80 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); | 55 TabContentsWrapper* tab_contents = browser()->GetSelectedTabContentsWrapper(); |
| 56 browser()->ShowCollectedCookiesDialog(tab_contents); |
81 | 57 |
82 // Navigate to another page. | 58 // Navigate to another page. |
83 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie2.html"))); | 59 ui_test_utils::NavigateToURL( |
| 60 browser(), test_server()->GetURL("files/cookie2.html")); |
84 } | 61 } |
OLD | NEW |