| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 int window_count = 0; | 37 int window_count = 0; |
| 38 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 38 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 39 EXPECT_EQ(1, window_count); | 39 EXPECT_EQ(1, window_count); |
| 40 #ifdef NDEBUG | 40 #ifdef NDEBUG |
| 41 ASSERT_FALSE(automation()->GetBrowserWindowCount(NULL)); | 41 ASSERT_FALSE(automation()->GetBrowserWindowCount(NULL)); |
| 42 #endif | 42 #endif |
| 43 } | 43 } |
| 44 | 44 |
| 45 TEST_F(AutomationProxyTest, GetBrowserWindow) { | 45 TEST_F(AutomationProxyTest, GetBrowserWindow) { |
| 46 { | 46 { |
| 47 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 47 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 48 ASSERT_TRUE(window.get()); | 48 ASSERT_TRUE(window.get()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 { | 51 { |
| 52 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(-1)); | 52 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(-1)); |
| 53 ASSERT_FALSE(window.get()); | 53 ASSERT_FALSE(window.get()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 { | 56 { |
| 57 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(1)); | 57 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(1)); |
| 58 ASSERT_FALSE(window.get()); | 58 ASSERT_FALSE(window.get()); |
| 59 } | 59 } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // TODO(port): This test is for Chrome Views, which we only use on Windows. | 62 // TODO(port): This test is for Chrome Views, which we only use on Windows. |
| 63 // Maybe split this into a _win.cc file? | 63 // Maybe split this into a _win.cc file? |
| 64 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
| 65 TEST_F(AutomationProxyVisibleTest, WindowGetViewBounds) { | 65 TEST_F(AutomationProxyVisibleTest, WindowGetViewBounds) { |
| 66 { | 66 { |
| 67 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 67 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 68 ASSERT_TRUE(browser.get()); | 68 ASSERT_TRUE(browser.get()); |
| 69 scoped_ptr<WindowProxy> window(browser->GetWindow()); | 69 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
| 70 ASSERT_TRUE(window.get()); | 70 ASSERT_TRUE(window.get()); |
| 71 | 71 |
| 72 scoped_ptr<TabProxy> tab1(browser->GetTab(0)); | 72 scoped_refptr<TabProxy> tab1(browser->GetTab(0)); |
| 73 ASSERT_TRUE(tab1.get()); | 73 ASSERT_TRUE(tab1.get()); |
| 74 GURL tab1_url; | 74 GURL tab1_url; |
| 75 ASSERT_TRUE(tab1->GetCurrentURL(&tab1_url)); | 75 ASSERT_TRUE(tab1->GetCurrentURL(&tab1_url)); |
| 76 | 76 |
| 77 // Add another tab so we can simulate dragging. | 77 // Add another tab so we can simulate dragging. |
| 78 ASSERT_TRUE(browser->AppendTab(GURL("about:"))); | 78 ASSERT_TRUE(browser->AppendTab(GURL("about:"))); |
| 79 | 79 |
| 80 scoped_ptr<TabProxy> tab2(browser->GetTab(1)); | 80 scoped_refptr<TabProxy> tab2(browser->GetTab(1)); |
| 81 ASSERT_TRUE(tab2.get()); | 81 ASSERT_TRUE(tab2.get()); |
| 82 GURL tab2_url; | 82 GURL tab2_url; |
| 83 ASSERT_TRUE(tab2->GetCurrentURL(&tab2_url)); | 83 ASSERT_TRUE(tab2->GetCurrentURL(&tab2_url)); |
| 84 | 84 |
| 85 EXPECT_NE(tab1_url.spec(), tab2_url.spec()); | 85 EXPECT_NE(tab1_url.spec(), tab2_url.spec()); |
| 86 | 86 |
| 87 gfx::Rect bounds; | 87 gfx::Rect bounds; |
| 88 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_0, &bounds, false)); | 88 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_0, &bounds, false)); |
| 89 EXPECT_GT(bounds.x(), 0); | 89 EXPECT_GT(bounds.x(), 0); |
| 90 EXPECT_GT(bounds.width(), 0); | 90 EXPECT_GT(bounds.width(), 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 114 POINT start; | 114 POINT start; |
| 115 POINT end; | 115 POINT end; |
| 116 start.x = bounds.x() + bounds.width() / 2; | 116 start.x = bounds.x() + bounds.width() / 2; |
| 117 start.y = bounds.y() + bounds.height() / 2; | 117 start.y = bounds.y() + bounds.height() / 2; |
| 118 end.x = start.x + 2 * bounds.width() / 3; | 118 end.x = start.x + 2 * bounds.width() / 3; |
| 119 end.y = start.y; | 119 end.y = start.y; |
| 120 ASSERT_TRUE(browser->SimulateDrag(start, end, | 120 ASSERT_TRUE(browser->SimulateDrag(start, end, |
| 121 views::Event::EF_LEFT_BUTTON_DOWN)); | 121 views::Event::EF_LEFT_BUTTON_DOWN)); |
| 122 | 122 |
| 123 // Check to see that the drag event successfully swapped the two tabs. | 123 // Check to see that the drag event successfully swapped the two tabs. |
| 124 tab1.reset(browser->GetTab(0)); | 124 tab1 = browser->GetTab(0); |
| 125 ASSERT_TRUE(tab1.get()); | 125 ASSERT_TRUE(tab1.get()); |
| 126 GURL tab1_new_url; | 126 GURL tab1_new_url; |
| 127 ASSERT_TRUE(tab1->GetCurrentURL(&tab1_new_url)); | 127 ASSERT_TRUE(tab1->GetCurrentURL(&tab1_new_url)); |
| 128 | 128 |
| 129 tab2.reset(browser->GetTab(1)); | 129 tab2 = browser->GetTab(1); |
| 130 ASSERT_TRUE(tab2.get()); | 130 ASSERT_TRUE(tab2.get()); |
| 131 GURL tab2_new_url; | 131 GURL tab2_new_url; |
| 132 ASSERT_TRUE(tab2->GetCurrentURL(&tab2_new_url)); | 132 ASSERT_TRUE(tab2->GetCurrentURL(&tab2_new_url)); |
| 133 | 133 |
| 134 EXPECT_EQ(tab1_url.spec(), tab2_new_url.spec()); | 134 EXPECT_EQ(tab1_url.spec(), tab2_new_url.spec()); |
| 135 EXPECT_EQ(tab2_url.spec(), tab1_new_url.spec()); | 135 EXPECT_EQ(tab2_url.spec(), tab1_new_url.spec()); |
| 136 | 136 |
| 137 */ | 137 */ |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 #endif // defined(OS_WIN) | 140 #endif // defined(OS_WIN) |
| 141 | 141 |
| 142 TEST_F(AutomationProxyTest, GetTabCount) { | 142 TEST_F(AutomationProxyTest, GetTabCount) { |
| 143 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 143 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 144 ASSERT_TRUE(window.get()); | 144 ASSERT_TRUE(window.get()); |
| 145 | 145 |
| 146 int tab_count = 0; | 146 int tab_count = 0; |
| 147 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 147 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
| 148 ASSERT_EQ(1, tab_count); | 148 ASSERT_EQ(1, tab_count); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TEST_F(AutomationProxyTest, GetActiveTabIndex) { | 151 TEST_F(AutomationProxyTest, GetActiveTabIndex) { |
| 152 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 152 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 153 ASSERT_TRUE(window.get()); | 153 ASSERT_TRUE(window.get()); |
| 154 | 154 |
| 155 int active_tab_index = -1; | 155 int active_tab_index = -1; |
| 156 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 156 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 157 ASSERT_EQ(0, active_tab_index); | 157 ASSERT_EQ(0, active_tab_index); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST_F(AutomationProxyVisibleTest, AppendTab) { | 160 TEST_F(AutomationProxyVisibleTest, AppendTab) { |
| 161 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 161 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 162 ASSERT_TRUE(window.get()); | 162 ASSERT_TRUE(window.get()); |
| 163 | 163 |
| 164 int original_tab_count; | 164 int original_tab_count; |
| 165 ASSERT_TRUE(window->GetTabCount(&original_tab_count)); | 165 ASSERT_TRUE(window->GetTabCount(&original_tab_count)); |
| 166 ASSERT_EQ(1, original_tab_count); // By default there are 2 tabs opened. | 166 ASSERT_EQ(1, original_tab_count); // By default there are 2 tabs opened. |
| 167 | 167 |
| 168 int original_active_tab_index; | 168 int original_active_tab_index; |
| 169 ASSERT_TRUE(window->GetActiveTabIndex(&original_active_tab_index)); | 169 ASSERT_TRUE(window->GetActiveTabIndex(&original_active_tab_index)); |
| 170 ASSERT_EQ(0, original_active_tab_index); // By default 0-th tab is active | 170 ASSERT_EQ(0, original_active_tab_index); // By default 0-th tab is active |
| 171 | 171 |
| 172 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); | 172 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); |
| 173 int tab_count; | 173 int tab_count; |
| 174 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 174 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
| 175 ASSERT_EQ(original_tab_count + 1, tab_count); | 175 ASSERT_EQ(original_tab_count + 1, tab_count); |
| 176 | 176 |
| 177 int active_tab_index = -1; | 177 int active_tab_index = -1; |
| 178 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 178 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 179 ASSERT_EQ(tab_count - 1, active_tab_index); | 179 ASSERT_EQ(tab_count - 1, active_tab_index); |
| 180 ASSERT_NE(original_active_tab_index, active_tab_index); | 180 ASSERT_NE(original_active_tab_index, active_tab_index); |
| 181 | 181 |
| 182 FilePath filename(test_data_directory_); | 182 FilePath filename(test_data_directory_); |
| 183 filename = filename.AppendASCII("title2.html"); | 183 filename = filename.AppendASCII("title2.html"); |
| 184 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(filename))); | 184 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(filename))); |
| 185 | 185 |
| 186 int appended_tab_index; | 186 int appended_tab_index; |
| 187 // Append tab will also be active tab | 187 // Append tab will also be active tab |
| 188 ASSERT_TRUE(window->GetActiveTabIndex(&appended_tab_index)); | 188 ASSERT_TRUE(window->GetActiveTabIndex(&appended_tab_index)); |
| 189 | 189 |
| 190 scoped_ptr<TabProxy> tab(window->GetTab(appended_tab_index)); | 190 scoped_refptr<TabProxy> tab(window->GetTab(appended_tab_index)); |
| 191 ASSERT_TRUE(tab.get()); | 191 ASSERT_TRUE(tab.get()); |
| 192 std::wstring title; | 192 std::wstring title; |
| 193 ASSERT_TRUE(tab->GetTabTitle(&title)); | 193 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 194 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 194 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 TEST_F(AutomationProxyTest, ActivateTab) { | 197 TEST_F(AutomationProxyTest, ActivateTab) { |
| 198 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 198 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 199 ASSERT_TRUE(window.get()); | 199 ASSERT_TRUE(window.get()); |
| 200 | 200 |
| 201 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); | 201 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); |
| 202 | 202 |
| 203 int at_index = 1; | 203 int at_index = 1; |
| 204 ASSERT_TRUE(window->ActivateTab(at_index)); | 204 ASSERT_TRUE(window->ActivateTab(at_index)); |
| 205 int active_tab_index = -1; | 205 int active_tab_index = -1; |
| 206 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 206 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 207 ASSERT_EQ(at_index, active_tab_index); | 207 ASSERT_EQ(at_index, active_tab_index); |
| 208 | 208 |
| 209 at_index = 0; | 209 at_index = 0; |
| 210 ASSERT_TRUE(window->ActivateTab(at_index)); | 210 ASSERT_TRUE(window->ActivateTab(at_index)); |
| 211 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 211 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 212 ASSERT_EQ(at_index, active_tab_index); | 212 ASSERT_EQ(at_index, active_tab_index); |
| 213 } | 213 } |
| 214 | 214 |
| 215 | 215 |
| 216 TEST_F(AutomationProxyTest, GetTab) { | 216 TEST_F(AutomationProxyTest, GetTab) { |
| 217 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 217 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 218 ASSERT_TRUE(window.get()); | 218 ASSERT_TRUE(window.get()); |
| 219 { | 219 { |
| 220 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 220 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 221 ASSERT_TRUE(tab.get()); | 221 ASSERT_TRUE(tab.get()); |
| 222 std::wstring title; | 222 std::wstring title; |
| 223 ASSERT_TRUE(tab->GetTabTitle(&title)); | 223 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 224 // BUG [634097] : expected title should be "about:blank" | 224 // BUG [634097] : expected title should be "about:blank" |
| 225 ASSERT_STREQ(L"", title.c_str()); | 225 ASSERT_STREQ(L"", title.c_str()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 { | 228 { |
| 229 ASSERT_FALSE(window->GetTab(-1)); | 229 ASSERT_FALSE(window->GetTab(-1)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 { | 232 { |
| 233 scoped_ptr<TabProxy> tab; | 233 scoped_refptr<TabProxy> tab(window->GetTab(1)); |
| 234 tab.reset(window->GetTab(1)); | |
| 235 ASSERT_FALSE(tab.get()); | 234 ASSERT_FALSE(tab.get()); |
| 236 } | 235 } |
| 237 }; | 236 }; |
| 238 | 237 |
| 239 TEST_F(AutomationProxyTest, NavigateToURL) { | 238 TEST_F(AutomationProxyTest, NavigateToURL) { |
| 240 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 239 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 241 ASSERT_TRUE(window.get()); | 240 ASSERT_TRUE(window.get()); |
| 242 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 241 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 243 ASSERT_TRUE(tab.get()); | 242 ASSERT_TRUE(tab.get()); |
| 244 | 243 |
| 245 std::wstring title; | 244 std::wstring title; |
| 246 ASSERT_TRUE(tab->GetTabTitle(&title)); | 245 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 247 // BUG [634097] : expected title should be "about:blank" | 246 // BUG [634097] : expected title should be "about:blank" |
| 248 ASSERT_STREQ(L"", title.c_str()); | 247 ASSERT_STREQ(L"", title.c_str()); |
| 249 | 248 |
| 250 FilePath filename(test_data_directory_); | 249 FilePath filename(test_data_directory_); |
| 251 filename = filename.AppendASCII("title2.html"); | 250 filename = filename.AppendASCII("title2.html"); |
| 252 | 251 |
| 253 tab->NavigateToURL(net::FilePathToFileURL(filename)); | 252 tab->NavigateToURL(net::FilePathToFileURL(filename)); |
| 254 ASSERT_TRUE(tab->GetTabTitle(&title)); | 253 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 255 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 254 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 256 | 255 |
| 257 // TODO(vibhor) : Add a test using testserver. | 256 // TODO(vibhor) : Add a test using testserver. |
| 258 } | 257 } |
| 259 | 258 |
| 260 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout1) { | 259 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout1) { |
| 261 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 260 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 262 ASSERT_TRUE(window.get()); | 261 ASSERT_TRUE(window.get()); |
| 263 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 262 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 264 ASSERT_TRUE(tab.get()); | 263 ASSERT_TRUE(tab.get()); |
| 265 | 264 |
| 266 FilePath filename(test_data_directory_); | 265 FilePath filename(test_data_directory_); |
| 267 filename = filename.AppendASCII("title2.html"); | 266 filename = filename.AppendASCII("title2.html"); |
| 268 | 267 |
| 269 bool is_timeout; | 268 bool is_timeout; |
| 270 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), | 269 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), |
| 271 5000, &is_timeout); | 270 5000, &is_timeout); |
| 272 ASSERT_FALSE(is_timeout); | 271 ASSERT_FALSE(is_timeout); |
| 273 | 272 |
| 274 std::wstring title; | 273 std::wstring title; |
| 275 ASSERT_TRUE(tab->GetTabTitle(&title)); | 274 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 276 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 275 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 277 | 276 |
| 278 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), | 277 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), |
| 279 1, &is_timeout); | 278 1, &is_timeout); |
| 280 ASSERT_TRUE(is_timeout); | 279 ASSERT_TRUE(is_timeout); |
| 281 } | 280 } |
| 282 | 281 |
| 283 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) { | 282 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) { |
| 284 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 283 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 285 ASSERT_TRUE(window.get()); | 284 ASSERT_TRUE(window.get()); |
| 286 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 285 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 287 tab.reset(window->GetTab(0)); | |
| 288 ASSERT_TRUE(tab.get()); | 286 ASSERT_TRUE(tab.get()); |
| 289 | 287 |
| 290 FilePath filename1(test_data_directory_); | 288 FilePath filename1(test_data_directory_); |
| 291 filename1 = filename1.AppendASCII("title1.html"); | 289 filename1 = filename1.AppendASCII("title1.html"); |
| 292 | 290 |
| 293 bool is_timeout; | 291 bool is_timeout; |
| 294 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename1), | 292 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename1), |
| 295 1, &is_timeout); | 293 1, &is_timeout); |
| 296 ASSERT_TRUE(is_timeout); | 294 ASSERT_TRUE(is_timeout); |
| 297 | 295 |
| 298 FilePath filename2(test_data_directory_); | 296 FilePath filename2(test_data_directory_); |
| 299 filename2 = filename2.AppendASCII("title1.html"); | 297 filename2 = filename2.AppendASCII("title1.html"); |
| 300 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), | 298 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), |
| 301 5000, &is_timeout); | 299 5000, &is_timeout); |
| 302 ASSERT_FALSE(is_timeout); | 300 ASSERT_FALSE(is_timeout); |
| 303 } | 301 } |
| 304 | 302 |
| 305 TEST_F(AutomationProxyTest, GoBackForward) { | 303 TEST_F(AutomationProxyTest, GoBackForward) { |
| 306 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 304 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 307 ASSERT_TRUE(window.get()); | 305 ASSERT_TRUE(window.get()); |
| 308 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 306 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 309 ASSERT_TRUE(tab.get()); | 307 ASSERT_TRUE(tab.get()); |
| 310 | 308 |
| 311 std::wstring title; | 309 std::wstring title; |
| 312 ASSERT_TRUE(tab->GetTabTitle(&title)); | 310 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 313 // BUG [634097] : expected title should be "about:blank" | 311 // BUG [634097] : expected title should be "about:blank" |
| 314 ASSERT_STREQ(L"", title.c_str()); | 312 ASSERT_STREQ(L"", title.c_str()); |
| 315 | 313 |
| 316 ASSERT_FALSE(tab->GoBack()); | 314 ASSERT_FALSE(tab->GoBack()); |
| 317 ASSERT_TRUE(tab->GetTabTitle(&title)); | 315 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 318 ASSERT_STREQ(L"", title.c_str()); | 316 ASSERT_STREQ(L"", title.c_str()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 331 ASSERT_TRUE(tab->GoForward()); | 329 ASSERT_TRUE(tab->GoForward()); |
| 332 ASSERT_TRUE(tab->GetTabTitle(&title)); | 330 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 333 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 331 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 334 | 332 |
| 335 ASSERT_FALSE(tab->GoForward()); | 333 ASSERT_FALSE(tab->GoForward()); |
| 336 ASSERT_TRUE(tab->GetTabTitle(&title)); | 334 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 337 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 335 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 338 } | 336 } |
| 339 | 337 |
| 340 TEST_F(AutomationProxyTest, GetCurrentURL) { | 338 TEST_F(AutomationProxyTest, GetCurrentURL) { |
| 341 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 339 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 342 ASSERT_TRUE(window.get()); | 340 ASSERT_TRUE(window.get()); |
| 343 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 341 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 344 ASSERT_TRUE(tab.get()); | 342 ASSERT_TRUE(tab.get()); |
| 345 GURL url; | 343 GURL url; |
| 346 ASSERT_TRUE(tab->GetCurrentURL(&url)); | 344 ASSERT_TRUE(tab->GetCurrentURL(&url)); |
| 347 ASSERT_STREQ("about:blank", url.spec().c_str()); | 345 ASSERT_STREQ("about:blank", url.spec().c_str()); |
| 348 | 346 |
| 349 FilePath filename(test_data_directory_); | 347 FilePath filename(test_data_directory_); |
| 350 filename = filename.AppendASCII("cookie1.html"); | 348 filename = filename.AppendASCII("cookie1.html"); |
| 351 GURL newurl = net::FilePathToFileURL(filename); | 349 GURL newurl = net::FilePathToFileURL(filename); |
| 352 ASSERT_TRUE(tab->NavigateToURL(newurl)); | 350 ASSERT_TRUE(tab->NavigateToURL(newurl)); |
| 353 ASSERT_TRUE(tab->GetCurrentURL(&url)); | 351 ASSERT_TRUE(tab->GetCurrentURL(&url)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 364 launch_arguments_ = CommandLine(L""); | 362 launch_arguments_ = CommandLine(L""); |
| 365 launch_arguments_.AppendLooseValue(document1_.ToWStringHack()); | 363 launch_arguments_.AppendLooseValue(document1_.ToWStringHack()); |
| 366 launch_arguments_.AppendLooseValue(document2_.ToWStringHack()); | 364 launch_arguments_.AppendLooseValue(document2_.ToWStringHack()); |
| 367 } | 365 } |
| 368 | 366 |
| 369 FilePath document1_; | 367 FilePath document1_; |
| 370 FilePath document2_; | 368 FilePath document2_; |
| 371 }; | 369 }; |
| 372 | 370 |
| 373 TEST_F(AutomationProxyTest2, GetActiveTabIndex) { | 371 TEST_F(AutomationProxyTest2, GetActiveTabIndex) { |
| 374 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 372 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 375 ASSERT_TRUE(window.get()); | 373 ASSERT_TRUE(window.get()); |
| 376 | 374 |
| 377 int active_tab_index = -1; | 375 int active_tab_index = -1; |
| 378 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 376 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 379 int tab_count; | 377 int tab_count; |
| 380 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 378 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
| 381 ASSERT_EQ(0, active_tab_index); | 379 ASSERT_EQ(0, active_tab_index); |
| 382 int at_index = 1; | 380 int at_index = 1; |
| 383 ASSERT_TRUE(window->ActivateTab(at_index)); | 381 ASSERT_TRUE(window->ActivateTab(at_index)); |
| 384 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 382 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 385 ASSERT_EQ(at_index, active_tab_index); | 383 ASSERT_EQ(at_index, active_tab_index); |
| 386 } | 384 } |
| 387 | 385 |
| 388 TEST_F(AutomationProxyTest2, GetTabTitle) { | 386 TEST_F(AutomationProxyTest2, GetTabTitle) { |
| 389 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 387 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 390 ASSERT_TRUE(window.get()); | 388 ASSERT_TRUE(window.get()); |
| 391 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 389 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 392 ASSERT_TRUE(tab.get()); | 390 ASSERT_TRUE(tab.get()); |
| 393 std::wstring title; | 391 std::wstring title; |
| 394 ASSERT_TRUE(tab->GetTabTitle(&title)); | 392 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 395 ASSERT_STREQ(L"title1.html", title.c_str()); | 393 ASSERT_STREQ(L"title1.html", title.c_str()); |
| 396 | 394 |
| 397 tab.reset(window->GetTab(1)); | 395 tab = window->GetTab(1); |
| 398 ASSERT_TRUE(tab.get()); | 396 ASSERT_TRUE(tab.get()); |
| 399 ASSERT_TRUE(tab->GetTabTitle(&title)); | 397 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 400 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 398 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 401 } | 399 } |
| 402 | 400 |
| 403 TEST_F(AutomationProxyTest, Cookies) { | 401 TEST_F(AutomationProxyTest, Cookies) { |
| 404 GURL url("http://mojo.jojo.google.com"); | 402 GURL url("http://mojo.jojo.google.com"); |
| 405 std::string value_result; | 403 std::string value_result; |
| 406 | 404 |
| 407 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 405 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 408 ASSERT_TRUE(window.get()); | 406 ASSERT_TRUE(window.get()); |
| 409 | 407 |
| 410 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 408 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 411 ASSERT_TRUE(tab.get()); | 409 ASSERT_TRUE(tab.get()); |
| 412 | 410 |
| 413 // test setting the cookie: | 411 // test setting the cookie: |
| 414 ASSERT_TRUE(tab->SetCookie(url, "foo=baz")); | 412 ASSERT_TRUE(tab->SetCookie(url, "foo=baz")); |
| 415 | 413 |
| 416 ASSERT_TRUE(tab->GetCookieByName(url, "foo", &value_result)); | 414 ASSERT_TRUE(tab->GetCookieByName(url, "foo", &value_result)); |
| 417 ASSERT_FALSE(value_result.empty()); | 415 ASSERT_FALSE(value_result.empty()); |
| 418 ASSERT_STREQ("baz", value_result.c_str()); | 416 ASSERT_STREQ("baz", value_result.c_str()); |
| 419 | 417 |
| 420 // test clearing the cookie: | 418 // test clearing the cookie: |
| 421 ASSERT_TRUE(tab->SetCookie(url, "foo=")); | 419 ASSERT_TRUE(tab->SetCookie(url, "foo=")); |
| 422 | 420 |
| 423 ASSERT_TRUE(tab->GetCookieByName(url, "foo", &value_result)); | 421 ASSERT_TRUE(tab->GetCookieByName(url, "foo", &value_result)); |
| 424 ASSERT_TRUE(value_result.empty()); | 422 ASSERT_TRUE(value_result.empty()); |
| 425 | 423 |
| 426 // now, test that we can get multiple cookies: | 424 // now, test that we can get multiple cookies: |
| 427 ASSERT_TRUE(tab->SetCookie(url, "foo1=baz1")); | 425 ASSERT_TRUE(tab->SetCookie(url, "foo1=baz1")); |
| 428 ASSERT_TRUE(tab->SetCookie(url, "foo2=baz2")); | 426 ASSERT_TRUE(tab->SetCookie(url, "foo2=baz2")); |
| 429 | 427 |
| 430 ASSERT_TRUE(tab->GetCookies(url, &value_result)); | 428 ASSERT_TRUE(tab->GetCookies(url, &value_result)); |
| 431 ASSERT_FALSE(value_result.empty()); | 429 ASSERT_FALSE(value_result.empty()); |
| 432 EXPECT_TRUE(value_result.find("foo1=baz1") != std::string::npos); | 430 EXPECT_TRUE(value_result.find("foo1=baz1") != std::string::npos); |
| 433 EXPECT_TRUE(value_result.find("foo2=baz2") != std::string::npos); | 431 EXPECT_TRUE(value_result.find("foo2=baz2") != std::string::npos); |
| 434 } | 432 } |
| 435 | 433 |
| 436 // TODO(port): Determine what tests need this and port. | 434 // TODO(port): Determine what tests need this and port. |
| 437 #if defined(OS_WIN) | 435 #if defined(OS_WIN) |
| 438 TEST_F(AutomationProxyTest, GetHWND) { | 436 TEST_F(AutomationProxyTest, GetHWND) { |
| 439 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 437 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 440 ASSERT_TRUE(browser.get()); | 438 ASSERT_TRUE(browser.get()); |
| 441 scoped_ptr<WindowProxy> window(browser->GetWindow()); | 439 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
| 442 ASSERT_TRUE(window.get()); | 440 ASSERT_TRUE(window.get()); |
| 443 | 441 |
| 444 HWND handle; | 442 HWND handle; |
| 445 ASSERT_TRUE(window->GetHWND(&handle)); | 443 ASSERT_TRUE(window->GetHWND(&handle)); |
| 446 ASSERT_TRUE(handle); | 444 ASSERT_TRUE(handle); |
| 447 } | 445 } |
| 448 #endif | 446 #endif |
| 449 | 447 |
| 450 TEST_F(AutomationProxyTest, NavigateToURLAsync) { | 448 TEST_F(AutomationProxyTest, NavigateToURLAsync) { |
| 451 AutomationProxy* automation_object = automation(); | 449 AutomationProxy* automation_object = automation(); |
| 452 scoped_ptr<BrowserProxy> window(automation_object->GetBrowserWindow(0)); | 450 scoped_refptr<BrowserProxy> window(automation_object->GetBrowserWindow(0)); |
| 453 ASSERT_TRUE(window.get()); | 451 ASSERT_TRUE(window.get()); |
| 454 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 452 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 455 ASSERT_TRUE(tab.get()); | 453 ASSERT_TRUE(tab.get()); |
| 456 | 454 |
| 457 FilePath filename(test_data_directory_); | 455 FilePath filename(test_data_directory_); |
| 458 filename = filename.AppendASCII("cookie1.html"); | 456 filename = filename.AppendASCII("cookie1.html"); |
| 459 GURL newurl = net::FilePathToFileURL(filename); | 457 GURL newurl = net::FilePathToFileURL(filename); |
| 460 | 458 |
| 461 ASSERT_TRUE(tab->NavigateToURLAsync(newurl)); | 459 ASSERT_TRUE(tab->NavigateToURLAsync(newurl)); |
| 462 std::string value = WaitUntilCookieNonEmpty(tab.get(), newurl, "foo", 250, | 460 std::string value = WaitUntilCookieNonEmpty(tab.get(), newurl, "foo", 250, |
| 463 action_max_timeout_ms()); | 461 action_max_timeout_ms()); |
| 464 ASSERT_STREQ("baz", value.c_str()); | 462 ASSERT_STREQ("baz", value.c_str()); |
| 465 } | 463 } |
| 466 | 464 |
| 467 TEST_F(AutomationProxyTest, AcceleratorNewTab) { | 465 TEST_F(AutomationProxyTest, AcceleratorNewTab) { |
| 468 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 466 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 469 | 467 |
| 470 int tab_count = -1; | 468 int tab_count = -1; |
| 471 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 469 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
| 472 EXPECT_EQ(1, tab_count); | 470 EXPECT_EQ(1, tab_count); |
| 473 | 471 |
| 474 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); | 472 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); |
| 475 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 473 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
| 476 EXPECT_EQ(2, tab_count); | 474 EXPECT_EQ(2, tab_count); |
| 477 scoped_ptr<TabProxy> tab(window->GetTab(tab_count - 1)); | 475 scoped_refptr<TabProxy> tab(window->GetTab(tab_count - 1)); |
| 478 ASSERT_TRUE(tab.get()); | 476 ASSERT_TRUE(tab.get()); |
| 479 } | 477 } |
| 480 | 478 |
| 481 class AutomationProxyTest4 : public UITest { | 479 class AutomationProxyTest4 : public UITest { |
| 482 protected: | 480 protected: |
| 483 AutomationProxyTest4() : UITest() { | 481 AutomationProxyTest4() : UITest() { |
| 484 dom_automation_enabled_ = true; | 482 dom_automation_enabled_ = true; |
| 485 } | 483 } |
| 486 }; | 484 }; |
| 487 | 485 |
| 488 std::wstring CreateJSString(const std::wstring& value) { | 486 std::wstring CreateJSString(const std::wstring& value) { |
| 489 std::wstring jscript; | 487 std::wstring jscript; |
| 490 SStringPrintf(&jscript, | 488 SStringPrintf(&jscript, |
| 491 L"window.domAutomationController.send(%ls);", | 489 L"window.domAutomationController.send(%ls);", |
| 492 value.c_str()); | 490 value.c_str()); |
| 493 return jscript; | 491 return jscript; |
| 494 } | 492 } |
| 495 | 493 |
| 496 TEST_F(AutomationProxyTest4, StringValueIsEchoedByDomAutomationController) { | 494 TEST_F(AutomationProxyTest4, StringValueIsEchoedByDomAutomationController) { |
| 497 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 495 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 498 ASSERT_TRUE(window.get()); | 496 ASSERT_TRUE(window.get()); |
| 499 | 497 |
| 500 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 498 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 501 ASSERT_TRUE(tab.get()); | 499 ASSERT_TRUE(tab.get()); |
| 502 | 500 |
| 503 std::wstring expected(L"string"); | 501 std::wstring expected(L"string"); |
| 504 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); | 502 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); |
| 505 std::wstring actual; | 503 std::wstring actual; |
| 506 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); | 504 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); |
| 507 ASSERT_STREQ(expected.c_str(), actual.c_str()); | 505 ASSERT_STREQ(expected.c_str(), actual.c_str()); |
| 508 } | 506 } |
| 509 | 507 |
| 510 std::wstring BooleanToString(bool bool_value) { | 508 std::wstring BooleanToString(bool bool_value) { |
| 511 Value* value = Value::CreateBooleanValue(bool_value); | 509 Value* value = Value::CreateBooleanValue(bool_value); |
| 512 std::string json_string; | 510 std::string json_string; |
| 513 JSONStringValueSerializer serializer(&json_string); | 511 JSONStringValueSerializer serializer(&json_string); |
| 514 serializer.Serialize(*value); | 512 serializer.Serialize(*value); |
| 515 return UTF8ToWide(json_string); | 513 return UTF8ToWide(json_string); |
| 516 } | 514 } |
| 517 | 515 |
| 518 TEST_F(AutomationProxyTest4, BooleanValueIsEchoedByDomAutomationController) { | 516 TEST_F(AutomationProxyTest4, BooleanValueIsEchoedByDomAutomationController) { |
| 519 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 517 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 520 ASSERT_TRUE(window.get()); | 518 ASSERT_TRUE(window.get()); |
| 521 | 519 |
| 522 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 520 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 523 ASSERT_TRUE(tab.get()); | 521 ASSERT_TRUE(tab.get()); |
| 524 | 522 |
| 525 bool expected = true; | 523 bool expected = true; |
| 526 std::wstring jscript = CreateJSString(BooleanToString(expected)); | 524 std::wstring jscript = CreateJSString(BooleanToString(expected)); |
| 527 bool actual = false; | 525 bool actual = false; |
| 528 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"", jscript, &actual)); | 526 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"", jscript, &actual)); |
| 529 ASSERT_EQ(expected, actual); | 527 ASSERT_EQ(expected, actual); |
| 530 } | 528 } |
| 531 | 529 |
| 532 TEST_F(AutomationProxyTest4, NumberValueIsEchoedByDomAutomationController) { | 530 TEST_F(AutomationProxyTest4, NumberValueIsEchoedByDomAutomationController) { |
| 533 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 531 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 534 ASSERT_TRUE(window.get()); | 532 ASSERT_TRUE(window.get()); |
| 535 | 533 |
| 536 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 534 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 537 ASSERT_TRUE(tab.get()); | 535 ASSERT_TRUE(tab.get()); |
| 538 | 536 |
| 539 int expected = 1; | 537 int expected = 1; |
| 540 int actual = 0; | 538 int actual = 0; |
| 541 std::wstring expected_string; | 539 std::wstring expected_string; |
| 542 SStringPrintf(&expected_string, L"%d", expected); | 540 SStringPrintf(&expected_string, L"%d", expected); |
| 543 std::wstring jscript = CreateJSString(expected_string); | 541 std::wstring jscript = CreateJSString(expected_string); |
| 544 ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", jscript, &actual)); | 542 ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", jscript, &actual)); |
| 545 ASSERT_EQ(expected, actual); | 543 ASSERT_EQ(expected, actual); |
| 546 } | 544 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 564 }; | 562 }; |
| 565 | 563 |
| 566 std::wstring CreateJSStringForDOMQuery(const std::wstring& id) { | 564 std::wstring CreateJSStringForDOMQuery(const std::wstring& id) { |
| 567 std::wstring jscript(L"window.domAutomationController"); | 565 std::wstring jscript(L"window.domAutomationController"); |
| 568 StringAppendF(&jscript, L".send(document.getElementById('%ls').nodeName);", | 566 StringAppendF(&jscript, L".send(document.getElementById('%ls').nodeName);", |
| 569 id.c_str()); | 567 id.c_str()); |
| 570 return jscript; | 568 return jscript; |
| 571 } | 569 } |
| 572 | 570 |
| 573 TEST_F(AutomationProxyTest3, FrameDocumentCanBeAccessed) { | 571 TEST_F(AutomationProxyTest3, FrameDocumentCanBeAccessed) { |
| 574 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 572 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 575 ASSERT_TRUE(window.get()); | 573 ASSERT_TRUE(window.get()); |
| 576 | 574 |
| 577 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 575 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 578 ASSERT_TRUE(tab.get()); | 576 ASSERT_TRUE(tab.get()); |
| 579 | 577 |
| 580 std::wstring actual; | 578 std::wstring actual; |
| 581 std::wstring xpath1 = L""; // top level frame | 579 std::wstring xpath1 = L""; // top level frame |
| 582 std::wstring jscript1 = CreateJSStringForDOMQuery(L"myinput"); | 580 std::wstring jscript1 = CreateJSStringForDOMQuery(L"myinput"); |
| 583 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); | 581 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); |
| 584 ASSERT_EQ(L"INPUT", actual); | 582 ASSERT_EQ(L"INPUT", actual); |
| 585 | 583 |
| 586 std::wstring xpath2 = L"/html/body/iframe"; | 584 std::wstring xpath2 = L"/html/body/iframe"; |
| 587 std::wstring jscript2 = CreateJSStringForDOMQuery(L"myspan"); | 585 std::wstring jscript2 = CreateJSStringForDOMQuery(L"myspan"); |
| 588 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath2, jscript2, &actual)); | 586 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath2, jscript2, &actual)); |
| 589 ASSERT_EQ(L"SPAN", actual); | 587 ASSERT_EQ(L"SPAN", actual); |
| 590 | 588 |
| 591 std::wstring xpath3 = L"/html/body/iframe\n/html/body/iframe"; | 589 std::wstring xpath3 = L"/html/body/iframe\n/html/body/iframe"; |
| 592 std::wstring jscript3 = CreateJSStringForDOMQuery(L"mydiv"); | 590 std::wstring jscript3 = CreateJSStringForDOMQuery(L"mydiv"); |
| 593 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath3, jscript3, &actual)); | 591 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath3, jscript3, &actual)); |
| 594 ASSERT_EQ(L"DIV", actual); | 592 ASSERT_EQ(L"DIV", actual); |
| 595 | 593 |
| 596 // TODO(evanm): fix or remove this. | 594 // TODO(evanm): fix or remove this. |
| 597 // This part of the test appears to verify that executing JS fails | 595 // This part of the test appears to verify that executing JS fails |
| 598 // non-HTML pages, but the new tab is now HTML so this test isn't | 596 // non-HTML pages, but the new tab is now HTML so this test isn't |
| 599 // correct. | 597 // correct. |
| 600 #if 0 | 598 #if 0 |
| 601 // Open a new Destinations tab to execute script inside. | 599 // Open a new Destinations tab to execute script inside. |
| 602 window->RunCommand(IDC_NEWTAB); | 600 window->RunCommand(IDC_NEWTAB); |
| 603 tab.reset(window->GetTab(1)); | 601 tab = window->GetTab(1); |
| 604 ASSERT_TRUE(tab.get()); | 602 ASSERT_TRUE(tab.get()); |
| 605 ASSERT_TRUE(window->ActivateTab(1)); | 603 ASSERT_TRUE(window->ActivateTab(1)); |
| 606 | 604 |
| 607 ASSERT_FALSE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); | 605 ASSERT_FALSE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); |
| 608 #endif | 606 #endif |
| 609 } | 607 } |
| 610 | 608 |
| 611 // TODO(port): Need to port constrained_window_proxy.* first. | 609 // TODO(port): Need to port constrained_window_proxy.* first. |
| 612 #if defined(OS_WIN) | 610 #if defined(OS_WIN) |
| 613 TEST_F(AutomationProxyTest, ConstrainedWindowTest) { | 611 TEST_F(AutomationProxyTest, ConstrainedWindowTest) { |
| 614 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 612 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 615 ASSERT_TRUE(window.get()); | 613 ASSERT_TRUE(window.get()); |
| 616 | 614 |
| 617 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 615 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 618 tab.reset(window->GetTab(0)); | |
| 619 ASSERT_TRUE(tab.get()); | 616 ASSERT_TRUE(tab.get()); |
| 620 | 617 |
| 621 FilePath filename(test_data_directory_); | 618 FilePath filename(test_data_directory_); |
| 622 filename = filename.AppendASCII("constrained_files"); | 619 filename = filename.AppendASCII("constrained_files"); |
| 623 filename = filename.AppendASCII("constrained_window.html"); | 620 filename = filename.AppendASCII("constrained_window.html"); |
| 624 | 621 |
| 625 ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); | 622 ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); |
| 626 | 623 |
| 627 int count; | 624 int count; |
| 628 ASSERT_TRUE(tab->WaitForChildWindowCountToChange(0, &count, 5000)); | 625 ASSERT_TRUE(tab->WaitForChildWindowCountToChange(0, &count, 5000)); |
| 629 | 626 |
| 630 ASSERT_EQ(1, count); | 627 ASSERT_EQ(1, count); |
| 631 | 628 |
| 632 ConstrainedWindowProxy* cwindow = tab->GetConstrainedWindow(0); | 629 scoped_refptr<ConstrainedWindowProxy> cwindow = tab->GetConstrainedWindow(0); |
| 633 ASSERT_TRUE(cwindow); | 630 ASSERT_TRUE(cwindow.get()); |
| 634 | 631 |
| 635 std::wstring title; | 632 std::wstring title; |
| 636 ASSERT_TRUE(cwindow->GetTitle(&title)); | 633 ASSERT_TRUE(cwindow->GetTitle(&title)); |
| 637 std::wstring window_title = L"Pop-ups Blocked: 2"; | 634 std::wstring window_title = L"Pop-ups Blocked: 2"; |
| 638 ASSERT_STREQ(window_title.c_str(), title.c_str()); | 635 ASSERT_STREQ(window_title.c_str(), title.c_str()); |
| 639 delete cwindow; | |
| 640 } | 636 } |
| 641 | 637 |
| 642 TEST_F(AutomationProxyTest, CantEscapeByOnloadMoveto) { | 638 TEST_F(AutomationProxyTest, CantEscapeByOnloadMoveto) { |
| 643 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 639 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 644 ASSERT_TRUE(window.get()); | 640 ASSERT_TRUE(window.get()); |
| 645 | 641 |
| 646 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 642 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 647 tab.reset(window->GetTab(0)); | |
| 648 ASSERT_TRUE(tab.get()); | 643 ASSERT_TRUE(tab.get()); |
| 649 | 644 |
| 650 FilePath filename(test_data_directory_); | 645 FilePath filename(test_data_directory_); |
| 651 filename = filename.AppendASCII("constrained_files"); | 646 filename = filename.AppendASCII("constrained_files"); |
| 652 filename = filename.AppendASCII("constrained_window_onload_moveto.html"); | 647 filename = filename.AppendASCII("constrained_window_onload_moveto.html"); |
| 653 | 648 |
| 654 ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); | 649 ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); |
| 655 | 650 |
| 656 int count; | 651 int count; |
| 657 ASSERT_TRUE(tab->WaitForChildWindowCountToChange(0, &count, 5000)); | 652 ASSERT_TRUE(tab->WaitForChildWindowCountToChange(0, &count, 5000)); |
| 658 | 653 |
| 659 ASSERT_EQ(1, count); | 654 ASSERT_EQ(1, count); |
| 660 | 655 |
| 661 ConstrainedWindowProxy* cwindow = tab->GetConstrainedWindow(0); | 656 scoped_refptr<ConstrainedWindowProxy> cwindow = tab->GetConstrainedWindow(0); |
| 662 ASSERT_TRUE(cwindow); | 657 ASSERT_TRUE(cwindow.get()); |
| 663 | 658 |
| 664 gfx::Rect rect; | 659 gfx::Rect rect; |
| 665 bool is_timeout = false; | 660 bool is_timeout = false; |
| 666 ASSERT_TRUE(cwindow->GetBoundsWithTimeout(&rect, 1000, &is_timeout)); | 661 ASSERT_TRUE(cwindow->GetBoundsWithTimeout(&rect, 1000, &is_timeout)); |
| 667 ASSERT_FALSE(is_timeout); | 662 ASSERT_FALSE(is_timeout); |
| 668 ASSERT_NE(20, rect.x()); | 663 ASSERT_NE(20, rect.x()); |
| 669 ASSERT_NE(20, rect.y()); | 664 ASSERT_NE(20, rect.y()); |
| 670 } | 665 } |
| 671 #endif // defined(OS_WIN) | 666 #endif // defined(OS_WIN) |
| 672 | 667 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 const std::string& target) { | 791 const std::string& target) { |
| 797 messages_received_++; | 792 messages_received_++; |
| 798 message_ = message; | 793 message_ = message; |
| 799 origin_ = origin; | 794 origin_ = origin; |
| 800 target_ = target; | 795 target_ = target; |
| 801 PostQuitMessage(0); | 796 PostQuitMessage(0); |
| 802 } | 797 } |
| 803 | 798 |
| 804 TEST_F(ExternalTabTestType, CreateExternalTab) { | 799 TEST_F(ExternalTabTestType, CreateExternalTab) { |
| 805 HWND external_tab_container = NULL; | 800 HWND external_tab_container = NULL; |
| 806 scoped_ptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), | 801 scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), |
| 807 WS_POPUP, false, &external_tab_container)); | 802 WS_POPUP, false, &external_tab_container)); |
| 808 EXPECT_TRUE(tab != NULL); | 803 EXPECT_TRUE(tab != NULL); |
| 809 EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); | 804 EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); |
| 810 if (tab != NULL) { | 805 if (tab != NULL) { |
| 811 tab->NavigateInExternalTab(GURL(L"http://www.google.com")); | 806 tab->NavigateInExternalTab(GURL(L"http://www.google.com")); |
| 812 EXPECT_EQ(true, ExternalTabMessageLoop(external_tab_container, 1000)); | 807 EXPECT_EQ(true, ExternalTabMessageLoop(external_tab_container, 1000)); |
| 813 // Since the tab goes away lazily, wait a bit | 808 // Since the tab goes away lazily, wait a bit |
| 814 PlatformThread::Sleep(1000); | 809 PlatformThread::Sleep(1000); |
| 815 EXPECT_FALSE(tab->is_valid()); | 810 EXPECT_FALSE(tab->is_valid()); |
| 816 } | 811 } |
| 817 } | 812 } |
| 818 | 813 |
| 819 TEST_F(ExternalTabTestType, IncognitoMode) { | 814 TEST_F(ExternalTabTestType, IncognitoMode) { |
| 820 HWND external_tab_container = NULL; | 815 HWND external_tab_container = NULL; |
| 821 GURL url("http://anatomyofmelancholy.net"); | 816 GURL url("http://anatomyofmelancholy.net"); |
| 822 std::string value_result; | 817 std::string value_result; |
| 823 | 818 |
| 824 // Create incognito tab | 819 // Create incognito tab |
| 825 scoped_ptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), | 820 scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), |
| 826 WS_POPUP, true, &external_tab_container)); | 821 WS_POPUP, true, &external_tab_container)); |
| 827 EXPECT_TRUE(tab->SetCookie(url, "robert=burton; " | 822 EXPECT_TRUE(tab->SetCookie(url, "robert=burton; " |
| 828 "expires=Thu, 13 Oct 2011 05:04:03 UTC;")); | 823 "expires=Thu, 13 Oct 2011 05:04:03 UTC;")); |
| 829 EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); | 824 EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); |
| 830 EXPECT_EQ("burton", value_result); | 825 EXPECT_EQ("burton", value_result); |
| 831 tab.reset(NULL); | 826 tab = NULL; |
| 832 CloseBrowserAndServer(); | 827 CloseBrowserAndServer(); |
| 833 | 828 |
| 834 value_result.empty(); | 829 value_result.empty(); |
| 835 clear_profile_ = false; | 830 clear_profile_ = false; |
| 836 external_tab_container = NULL; | 831 external_tab_container = NULL; |
| 837 LaunchBrowserAndServer(); | 832 LaunchBrowserAndServer(); |
| 838 tab.reset(automation()->CreateExternalTab(NULL, gfx::Rect(), | 833 tab = automation()->CreateExternalTab(NULL, gfx::Rect(), |
| 839 WS_POPUP, false, &external_tab_container)); | 834 WS_POPUP, false, &external_tab_container); |
| 840 EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); | 835 EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); |
| 841 EXPECT_EQ("", value_result); | 836 EXPECT_EQ("", value_result); |
| 842 } | 837 } |
| 843 | 838 |
| 844 TEST_F(ExternalTabTestType, ExternalTabPostMessage) { | 839 TEST_F(ExternalTabTestType, ExternalTabPostMessage) { |
| 845 AutomationProxyForExternalTab* proxy = | 840 AutomationProxyForExternalTab* proxy = |
| 846 static_cast<AutomationProxyForExternalTab*>(automation()); | 841 static_cast<AutomationProxyForExternalTab*>(automation()); |
| 847 | 842 |
| 848 HWND external_tab_container = NULL; | 843 HWND external_tab_container = NULL; |
| 849 scoped_ptr<TabProxy> tab(proxy->CreateExternalTab(NULL, gfx::Rect(), | 844 scoped_refptr<TabProxy> tab(proxy->CreateExternalTab(NULL, gfx::Rect(), |
| 850 WS_POPUP, false, &external_tab_container)); | 845 WS_POPUP, false, &external_tab_container)); |
| 851 EXPECT_TRUE(tab != NULL); | 846 EXPECT_TRUE(tab != NULL); |
| 852 EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); | 847 EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); |
| 853 if (tab != NULL) { | 848 if (tab != NULL) { |
| 854 std::string content = | 849 std::string content = |
| 855 "data:text/html,<html><head><script>" | 850 "data:text/html,<html><head><script>" |
| 856 "function onload() {" | 851 "function onload() {" |
| 857 " window.externalHost.onmessage = onMessage;" | 852 " window.externalHost.onmessage = onMessage;" |
| 858 "}" | 853 "}" |
| 859 "function onMessage(evt) {" | 854 "function onMessage(evt) {" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 873 if (proxy->messages_received()) { | 868 if (proxy->messages_received()) { |
| 874 EXPECT_EQ("Hello from gtest", proxy->message()); | 869 EXPECT_EQ("Hello from gtest", proxy->message()); |
| 875 } | 870 } |
| 876 } | 871 } |
| 877 } | 872 } |
| 878 #endif // defined(OS_WIN) | 873 #endif // defined(OS_WIN) |
| 879 | 874 |
| 880 // TODO(port): Need to port autocomplete_edit_proxy.* first. | 875 // TODO(port): Need to port autocomplete_edit_proxy.* first. |
| 881 #if defined(OS_WIN) || defined(OS_LINUX) | 876 #if defined(OS_WIN) || defined(OS_LINUX) |
| 882 TEST_F(AutomationProxyTest, AutocompleteGetSetText) { | 877 TEST_F(AutomationProxyTest, AutocompleteGetSetText) { |
| 883 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 878 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 884 ASSERT_TRUE(browser.get()); | 879 ASSERT_TRUE(browser.get()); |
| 885 scoped_ptr<AutocompleteEditProxy> edit( | 880 scoped_refptr<AutocompleteEditProxy> edit( |
| 886 browser->GetAutocompleteEdit()); | 881 browser->GetAutocompleteEdit()); |
| 887 ASSERT_TRUE(edit.get()); | 882 ASSERT_TRUE(edit.get()); |
| 888 EXPECT_TRUE(edit->is_valid()); | 883 EXPECT_TRUE(edit->is_valid()); |
| 889 const std::wstring text_to_set = L"Lollerskates"; | 884 const std::wstring text_to_set = L"Lollerskates"; |
| 890 std::wstring actual_text; | 885 std::wstring actual_text; |
| 891 EXPECT_TRUE(edit->SetText(text_to_set)); | 886 EXPECT_TRUE(edit->SetText(text_to_set)); |
| 892 EXPECT_TRUE(edit->GetText(&actual_text)); | 887 EXPECT_TRUE(edit->GetText(&actual_text)); |
| 893 EXPECT_EQ(text_to_set, actual_text); | 888 EXPECT_EQ(text_to_set, actual_text); |
| 894 scoped_ptr<AutocompleteEditProxy> edit2( | 889 scoped_refptr<AutocompleteEditProxy> edit2( |
| 895 browser->GetAutocompleteEdit()); | 890 browser->GetAutocompleteEdit()); |
| 896 EXPECT_TRUE(edit2->GetText(&actual_text)); | 891 EXPECT_TRUE(edit2->GetText(&actual_text)); |
| 897 EXPECT_EQ(text_to_set, actual_text); | 892 EXPECT_EQ(text_to_set, actual_text); |
| 898 } | 893 } |
| 899 | 894 |
| 900 TEST_F(AutomationProxyTest, AutocompleteParallelProxy) { | 895 TEST_F(AutomationProxyTest, AutocompleteParallelProxy) { |
| 901 scoped_ptr<BrowserProxy> browser1(automation()->GetBrowserWindow(0)); | 896 scoped_refptr<BrowserProxy> browser1(automation()->GetBrowserWindow(0)); |
| 902 ASSERT_TRUE(browser1.get()); | 897 ASSERT_TRUE(browser1.get()); |
| 903 scoped_ptr<AutocompleteEditProxy> edit1( | 898 scoped_refptr<AutocompleteEditProxy> edit1( |
| 904 browser1->GetAutocompleteEdit()); | 899 browser1->GetAutocompleteEdit()); |
| 905 ASSERT_TRUE(edit1.get()); | 900 ASSERT_TRUE(edit1.get()); |
| 906 EXPECT_TRUE(browser1->RunCommand(IDC_NEW_WINDOW)); | 901 EXPECT_TRUE(browser1->RunCommand(IDC_NEW_WINDOW)); |
| 907 scoped_ptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); | 902 scoped_refptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); |
| 908 ASSERT_TRUE(browser2.get()); | 903 ASSERT_TRUE(browser2.get()); |
| 909 scoped_ptr<AutocompleteEditProxy> edit2( | 904 scoped_refptr<AutocompleteEditProxy> edit2( |
| 910 browser2->GetAutocompleteEdit()); | 905 browser2->GetAutocompleteEdit()); |
| 911 ASSERT_TRUE(edit2.get()); | 906 ASSERT_TRUE(edit2.get()); |
| 912 EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored( | 907 EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored( |
| 913 action_max_timeout_ms())); | 908 action_max_timeout_ms())); |
| 914 const std::wstring text_to_set1 = L"Lollerskates"; | 909 const std::wstring text_to_set1 = L"Lollerskates"; |
| 915 const std::wstring text_to_set2 = L"Roflcopter"; | 910 const std::wstring text_to_set2 = L"Roflcopter"; |
| 916 std::wstring actual_text1, actual_text2; | 911 std::wstring actual_text1, actual_text2; |
| 917 EXPECT_TRUE(edit1->SetText(text_to_set1)); | 912 EXPECT_TRUE(edit1->SetText(text_to_set1)); |
| 918 EXPECT_TRUE(edit2->SetText(text_to_set2)); | 913 EXPECT_TRUE(edit2->SetText(text_to_set2)); |
| 919 EXPECT_TRUE(edit1->GetText(&actual_text1)); | 914 EXPECT_TRUE(edit1->GetText(&actual_text1)); |
| 920 EXPECT_TRUE(edit2->GetText(&actual_text2)); | 915 EXPECT_TRUE(edit2->GetText(&actual_text2)); |
| 921 EXPECT_EQ(text_to_set1, actual_text1); | 916 EXPECT_EQ(text_to_set1, actual_text1); |
| 922 EXPECT_EQ(text_to_set2, actual_text2); | 917 EXPECT_EQ(text_to_set2, actual_text2); |
| 923 } | 918 } |
| 924 | 919 |
| 925 TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { | 920 TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { |
| 926 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 921 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 927 ASSERT_TRUE(browser.get()); | 922 ASSERT_TRUE(browser.get()); |
| 928 scoped_ptr<AutocompleteEditProxy> edit( | 923 scoped_refptr<AutocompleteEditProxy> edit( |
| 929 browser->GetAutocompleteEdit()); | 924 browser->GetAutocompleteEdit()); |
| 930 ASSERT_TRUE(edit.get()); | 925 ASSERT_TRUE(edit.get()); |
| 931 EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); | 926 EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); |
| 932 EXPECT_TRUE(edit->is_valid()); | 927 EXPECT_TRUE(edit->is_valid()); |
| 933 EXPECT_TRUE(edit->SetText(L"Roflcopter")); | 928 EXPECT_TRUE(edit->SetText(L"Roflcopter")); |
| 934 EXPECT_TRUE(edit->WaitForQuery(30000)); | 929 EXPECT_TRUE(edit->WaitForQuery(30000)); |
| 935 bool query_in_progress; | 930 bool query_in_progress; |
| 936 EXPECT_TRUE(edit->IsQueryInProgress(&query_in_progress)); | 931 EXPECT_TRUE(edit->IsQueryInProgress(&query_in_progress)); |
| 937 EXPECT_FALSE(query_in_progress); | 932 EXPECT_FALSE(query_in_progress); |
| 938 std::vector<AutocompleteMatchData> matches; | 933 std::vector<AutocompleteMatchData> matches; |
| 939 EXPECT_TRUE(edit->GetAutocompleteMatches(&matches)); | 934 EXPECT_TRUE(edit->GetAutocompleteMatches(&matches)); |
| 940 EXPECT_FALSE(matches.empty()); | 935 EXPECT_FALSE(matches.empty()); |
| 941 } | 936 } |
| 942 #endif // defined(OS_WIN) || defined(OS_LINUX) | 937 #endif // defined(OS_WIN) || defined(OS_LINUX) |
| 943 | 938 |
| 944 // Disabled because flaky see bug #5314. | 939 // Disabled because flaky see bug #5314. |
| 945 TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) { | 940 TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) { |
| 946 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 941 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 947 ASSERT_TRUE(browser.get()); | 942 ASSERT_TRUE(browser.get()); |
| 948 scoped_ptr<TabProxy> tab(browser->GetTab(0)); | 943 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
| 949 tab.reset(browser->GetTab(0)); | |
| 950 ASSERT_TRUE(tab.get()); | 944 ASSERT_TRUE(tab.get()); |
| 951 | 945 |
| 952 bool modal_dialog_showing = false; | 946 bool modal_dialog_showing = false; |
| 953 MessageBoxFlags::DialogButton button = MessageBoxFlags::DIALOGBUTTON_NONE; | 947 MessageBoxFlags::DialogButton button = MessageBoxFlags::DIALOGBUTTON_NONE; |
| 954 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 948 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
| 955 &button)); | 949 &button)); |
| 956 EXPECT_FALSE(modal_dialog_showing); | 950 EXPECT_FALSE(modal_dialog_showing); |
| 957 EXPECT_EQ(MessageBoxFlags::DIALOGBUTTON_NONE, button); | 951 EXPECT_EQ(MessageBoxFlags::DIALOGBUTTON_NONE, button); |
| 958 | 952 |
| 959 // Show a simple alert. | 953 // Show a simple alert. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 AutomationProxyTest5() { | 1026 AutomationProxyTest5() { |
| 1033 show_window_ = true; | 1027 show_window_ = true; |
| 1034 dom_automation_enabled_ = true; | 1028 dom_automation_enabled_ = true; |
| 1035 // We need to disable popup blocking to ensure that the RenderView | 1029 // We need to disable popup blocking to ensure that the RenderView |
| 1036 // instance for the popup actually closes. | 1030 // instance for the popup actually closes. |
| 1037 launch_arguments_.AppendSwitch(switches::kDisablePopupBlocking); | 1031 launch_arguments_.AppendSwitch(switches::kDisablePopupBlocking); |
| 1038 } | 1032 } |
| 1039 }; | 1033 }; |
| 1040 | 1034 |
| 1041 TEST_F(AutomationProxyTest5, TestLifetimeOfDomAutomationController) { | 1035 TEST_F(AutomationProxyTest5, TestLifetimeOfDomAutomationController) { |
| 1042 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 1036 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 1043 ASSERT_TRUE(window.get()); | 1037 ASSERT_TRUE(window.get()); |
| 1044 | 1038 |
| 1045 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 1039 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 1046 ASSERT_TRUE(tab.get()); | 1040 ASSERT_TRUE(tab.get()); |
| 1047 | 1041 |
| 1048 FilePath filename(test_data_directory_); | 1042 FilePath filename(test_data_directory_); |
| 1049 filename = filename.AppendASCII("dom_automation_test_with_popup.html"); | 1043 filename = filename.AppendASCII("dom_automation_test_with_popup.html"); |
| 1050 | 1044 |
| 1051 tab->NavigateToURL(net::FilePathToFileURL(filename)); | 1045 tab->NavigateToURL(net::FilePathToFileURL(filename)); |
| 1052 | 1046 |
| 1053 // Allow some time for the popup to show up and close. | 1047 // Allow some time for the popup to show up and close. |
| 1054 PlatformThread::Sleep(2000); | 1048 PlatformThread::Sleep(2000); |
| 1055 | 1049 |
| 1056 std::wstring expected(L"string"); | 1050 std::wstring expected(L"string"); |
| 1057 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); | 1051 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); |
| 1058 std::wstring actual; | 1052 std::wstring actual; |
| 1059 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); | 1053 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); |
| 1060 ASSERT_EQ(expected, actual); | 1054 ASSERT_EQ(expected, actual); |
| 1061 } | 1055 } |
| OLD | NEW |