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/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 std::string homepage_original; | 95 std::string homepage_original; |
96 std::swap(homepage_original, homepage_); | 96 std::swap(homepage_original, homepage_); |
97 | 97 |
98 UITestBase::SetLaunchSwitches(); | 98 UITestBase::SetLaunchSwitches(); |
99 | 99 |
100 // However, we *do* want the --homepage switch. | 100 // However, we *do* want the --homepage switch. |
101 std::swap(homepage_original, homepage_); | 101 std::swap(homepage_original, homepage_); |
102 launch_arguments_.AppendSwitchASCII(switches::kHomePage, homepage_); | 102 launch_arguments_.AppendSwitchASCII(switches::kHomePage, homepage_); |
103 } | 103 } |
104 | 104 |
105 void PyUITestBase::SetDownloadShelfVisible(bool is_visible, int window_index) { | |
106 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); | |
107 ASSERT_TRUE(browser_proxy.get()); | |
108 EXPECT_TRUE(browser_proxy->SetShelfVisible(is_visible)); | |
109 } | |
110 | |
111 bool PyUITestBase::IsDownloadShelfVisible(int window_index) { | |
112 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); | |
113 EXPECT_TRUE(browser_proxy.get()); | |
114 if (!browser_proxy.get()) | |
115 return false; | |
116 bool visible = false; | |
117 EXPECT_TRUE(browser_proxy->IsShelfVisible(&visible)); | |
118 return visible; | |
119 } | |
120 | |
121 void PyUITestBase::OpenFindInPage(int window_index) { | 105 void PyUITestBase::OpenFindInPage(int window_index) { |
122 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); | 106 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); |
123 ASSERT_TRUE(browser_proxy.get()); | 107 ASSERT_TRUE(browser_proxy.get()); |
124 EXPECT_TRUE(browser_proxy->OpenFindInPage()); | 108 EXPECT_TRUE(browser_proxy->OpenFindInPage()); |
125 } | 109 } |
126 | 110 |
127 bool PyUITestBase::IsFindInPageVisible(int window_index) { | 111 bool PyUITestBase::IsFindInPageVisible(int window_index) { |
128 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); | 112 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); |
129 EXPECT_TRUE(browser_proxy.get()); | 113 EXPECT_TRUE(browser_proxy.get()); |
130 if (!browser_proxy.get()) | 114 if (!browser_proxy.get()) |
131 return false; | 115 return false; |
132 bool is_visible; | 116 bool is_visible; |
133 EXPECT_TRUE(browser_proxy->IsFindWindowFullyVisible(&is_visible)); | 117 EXPECT_TRUE(browser_proxy->IsFindWindowFullyVisible(&is_visible)); |
134 return is_visible; | 118 return is_visible; |
135 } | 119 } |
136 | 120 |
137 FilePath PyUITestBase::GetDownloadDirectory() { | |
138 FilePath download_dir; | |
139 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | |
140 EXPECT_TRUE(tab_proxy.get()); | |
141 if (!tab_proxy.get()) | |
142 return download_dir; | |
143 EXPECT_TRUE(tab_proxy->GetDownloadDirectory(&download_dir)); | |
144 return download_dir; | |
145 } | |
146 | |
147 bool PyUITestBase::OpenNewBrowserWindow(bool show) { | 121 bool PyUITestBase::OpenNewBrowserWindow(bool show) { |
148 return automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, show); | 122 return automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, show); |
149 } | 123 } |
150 | 124 |
151 bool PyUITestBase::CloseBrowserWindow(int window_index) { | 125 bool PyUITestBase::CloseBrowserWindow(int window_index) { |
152 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); | 126 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); |
153 if (!browser_proxy.get()) | 127 if (!browser_proxy.get()) |
154 return false; | 128 return false; |
155 bool app_closed; | 129 bool app_closed; |
156 return CloseBrowser(browser_proxy.get(), &app_closed); | 130 return CloseBrowser(browser_proxy.get(), &app_closed); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 request, response); | 326 request, response); |
353 } else { | 327 } else { |
354 // TODO(craigdh): Determine specific cause. | 328 // TODO(craigdh): Determine specific cause. |
355 ErrorResponse("Chrome failed to respond", request, response); | 329 ErrorResponse("Chrome failed to respond", request, response); |
356 } | 330 } |
357 } | 331 } |
358 | 332 |
359 bool PyUITestBase::ResetToDefaultTheme() { | 333 bool PyUITestBase::ResetToDefaultTheme() { |
360 return automation()->ResetToDefaultTheme(); | 334 return automation()->ResetToDefaultTheme(); |
361 } | 335 } |
362 | |
363 bool PyUITestBase::SetCookie(const GURL& cookie_url, | |
364 const std::string& value, | |
365 int window_index, | |
366 int tab_index) { | |
367 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); | |
368 EXPECT_TRUE(browser_proxy.get()); | |
369 if (!browser_proxy.get()) | |
370 return false; | |
371 scoped_refptr<TabProxy> tab_proxy = browser_proxy->GetTab(tab_index); | |
372 EXPECT_TRUE(tab_proxy.get()); | |
373 if (!tab_proxy.get()) | |
374 return false; | |
375 return tab_proxy->SetCookie(cookie_url, value); | |
376 } | |
377 | |
378 std::string PyUITestBase::GetCookie(const GURL& cookie_url, | |
379 int window_index, | |
380 int tab_index) { | |
381 std::string cookie_val; | |
382 scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); | |
383 EXPECT_TRUE(browser_proxy.get()); | |
384 // TODO(phadjan.jr): figure out a way to unambiguously report error. | |
385 if (!browser_proxy.get()) | |
386 return cookie_val; | |
387 scoped_refptr<TabProxy> tab_proxy = browser_proxy->GetTab(tab_index); | |
388 EXPECT_TRUE(tab_proxy.get()); | |
389 if (!tab_proxy.get()) | |
390 return cookie_val; | |
391 EXPECT_TRUE(tab_proxy->GetCookies(cookie_url, &cookie_val)); | |
392 return cookie_val; | |
393 } | |
OLD | NEW |