| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 FilePath filename(test_data_directory_); | 255 FilePath filename(test_data_directory_); |
| 256 filename = filename.AppendASCII("title2.html"); | 256 filename = filename.AppendASCII("title2.html"); |
| 257 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(filename))); | 257 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(filename))); |
| 258 | 258 |
| 259 int appended_tab_index; | 259 int appended_tab_index; |
| 260 // Append tab will also be active tab | 260 // Append tab will also be active tab |
| 261 ASSERT_TRUE(window->GetActiveTabIndex(&appended_tab_index)); | 261 ASSERT_TRUE(window->GetActiveTabIndex(&appended_tab_index)); |
| 262 | 262 |
| 263 scoped_refptr<TabProxy> tab(window->GetTab(appended_tab_index)); | 263 scoped_refptr<TabProxy> tab(window->GetTab(appended_tab_index)); |
| 264 ASSERT_TRUE(tab.get()); | 264 ASSERT_TRUE(tab.get()); |
| 265 std::wstring title; | 265 string16 title; |
| 266 ASSERT_TRUE(tab->GetTabTitle(&title)); | 266 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 267 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 267 ASSERT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title); |
| 268 } | 268 } |
| 269 | 269 |
| 270 TEST_F(AutomationProxyTest, ActivateTab) { | 270 TEST_F(AutomationProxyTest, ActivateTab) { |
| 271 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 271 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 272 ASSERT_TRUE(window.get()); | 272 ASSERT_TRUE(window.get()); |
| 273 | 273 |
| 274 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); | 274 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); |
| 275 | 275 |
| 276 ASSERT_TRUE(window->ActivateTab(1)); | 276 ASSERT_TRUE(window->ActivateTab(1)); |
| 277 int active_tab_index = -1; | 277 int active_tab_index = -1; |
| 278 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 278 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 279 ASSERT_EQ(1, active_tab_index); | 279 ASSERT_EQ(1, active_tab_index); |
| 280 | 280 |
| 281 ASSERT_TRUE(window->ActivateTab(0)); | 281 ASSERT_TRUE(window->ActivateTab(0)); |
| 282 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 282 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 283 ASSERT_EQ(0, active_tab_index); | 283 ASSERT_EQ(0, active_tab_index); |
| 284 } | 284 } |
| 285 | 285 |
| 286 TEST_F(AutomationProxyTest, GetTab) { | 286 TEST_F(AutomationProxyTest, GetTab) { |
| 287 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 287 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 288 ASSERT_TRUE(window.get()); | 288 ASSERT_TRUE(window.get()); |
| 289 { | 289 { |
| 290 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 290 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 291 ASSERT_TRUE(tab.get()); | 291 ASSERT_TRUE(tab.get()); |
| 292 std::wstring title; | 292 string16 title; |
| 293 ASSERT_TRUE(tab->GetTabTitle(&title)); | 293 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 294 // BUG [634097] : expected title should be "about:blank" | 294 // BUG [634097] : expected title should be "about:blank" |
| 295 ASSERT_STREQ(L"", title.c_str()); | 295 ASSERT_EQ(string16(), title); |
| 296 } | 296 } |
| 297 | 297 |
| 298 { | 298 { |
| 299 ASSERT_FALSE(window->GetTab(-1)); | 299 ASSERT_FALSE(window->GetTab(-1)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 { | 302 { |
| 303 scoped_refptr<TabProxy> tab(window->GetTab(1)); | 303 scoped_refptr<TabProxy> tab(window->GetTab(1)); |
| 304 ASSERT_FALSE(tab.get()); | 304 ASSERT_FALSE(tab.get()); |
| 305 } | 305 } |
| 306 }; | 306 }; |
| 307 | 307 |
| 308 TEST_F(AutomationProxyTest, NavigateToURL) { | 308 TEST_F(AutomationProxyTest, NavigateToURL) { |
| 309 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 309 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 310 ASSERT_TRUE(window.get()); | 310 ASSERT_TRUE(window.get()); |
| 311 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 311 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 312 ASSERT_TRUE(tab.get()); | 312 ASSERT_TRUE(tab.get()); |
| 313 | 313 |
| 314 std::wstring title; | 314 string16 title; |
| 315 ASSERT_TRUE(tab->GetTabTitle(&title)); | 315 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 316 // BUG [634097] : expected title should be "about:blank" | 316 // BUG [634097] : expected title should be "about:blank" |
| 317 ASSERT_STREQ(L"", title.c_str()); | 317 ASSERT_EQ(string16(), title); |
| 318 | 318 |
| 319 FilePath filename(test_data_directory_); | 319 FilePath filename(test_data_directory_); |
| 320 filename = filename.AppendASCII("title2.html"); | 320 filename = filename.AppendASCII("title2.html"); |
| 321 | 321 |
| 322 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 322 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 323 tab->NavigateToURL(net::FilePathToFileURL(filename))); | 323 tab->NavigateToURL(net::FilePathToFileURL(filename))); |
| 324 ASSERT_TRUE(tab->GetTabTitle(&title)); | 324 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 325 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 325 ASSERT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title); |
| 326 | 326 |
| 327 // TODO(vibhor) : Add a test using testserver. | 327 // TODO(vibhor) : Add a test using testserver. |
| 328 } | 328 } |
| 329 | 329 |
| 330 TEST_F(AutomationProxyTest, GoBackForward) { | 330 TEST_F(AutomationProxyTest, GoBackForward) { |
| 331 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 331 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 332 ASSERT_TRUE(window.get()); | 332 ASSERT_TRUE(window.get()); |
| 333 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 333 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 334 ASSERT_TRUE(tab.get()); | 334 ASSERT_TRUE(tab.get()); |
| 335 | 335 |
| 336 std::wstring title; | 336 string16 title; |
| 337 ASSERT_TRUE(tab->GetTabTitle(&title)); | 337 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 338 // BUG [634097] : expected title should be "about:blank" | 338 // BUG [634097] : expected title should be "about:blank" |
| 339 ASSERT_STREQ(L"", title.c_str()); | 339 ASSERT_EQ(string16(), title); |
| 340 | 340 |
| 341 ASSERT_FALSE(tab->GoBack()); | 341 ASSERT_FALSE(tab->GoBack()); |
| 342 ASSERT_TRUE(tab->GetTabTitle(&title)); | 342 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 343 ASSERT_STREQ(L"", title.c_str()); | 343 ASSERT_EQ(string16(), title); |
| 344 | 344 |
| 345 FilePath filename(test_data_directory_); | 345 FilePath filename(test_data_directory_); |
| 346 filename = filename.AppendASCII("title2.html"); | 346 filename = filename.AppendASCII("title2.html"); |
| 347 ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); | 347 ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); |
| 348 ASSERT_TRUE(tab->GetTabTitle(&title)); | 348 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 349 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 349 ASSERT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title); |
| 350 | 350 |
| 351 ASSERT_TRUE(tab->GoBack()); | 351 ASSERT_TRUE(tab->GoBack()); |
| 352 ASSERT_TRUE(tab->GetTabTitle(&title)); | 352 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 353 // BUG [634097] : expected title should be "about:blank" | 353 // BUG [634097] : expected title should be "about:blank" |
| 354 ASSERT_STREQ(L"", title.c_str()); | 354 ASSERT_EQ(string16(), title.c_str()); |
| 355 | 355 |
| 356 ASSERT_TRUE(tab->GoForward()); | 356 ASSERT_TRUE(tab->GoForward()); |
| 357 ASSERT_TRUE(tab->GetTabTitle(&title)); | 357 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 358 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 358 ASSERT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title); |
| 359 | 359 |
| 360 ASSERT_FALSE(tab->GoForward()); | 360 ASSERT_FALSE(tab->GoForward()); |
| 361 ASSERT_TRUE(tab->GetTabTitle(&title)); | 361 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 362 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 362 ASSERT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title); |
| 363 } | 363 } |
| 364 | 364 |
| 365 TEST_F(AutomationProxyTest, GetCurrentURL) { | 365 TEST_F(AutomationProxyTest, GetCurrentURL) { |
| 366 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 366 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 367 ASSERT_TRUE(window.get()); | 367 ASSERT_TRUE(window.get()); |
| 368 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 368 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 369 ASSERT_TRUE(tab.get()); | 369 ASSERT_TRUE(tab.get()); |
| 370 GURL url; | 370 GURL url; |
| 371 ASSERT_TRUE(tab->GetCurrentURL(&url)); | 371 ASSERT_TRUE(tab->GetCurrentURL(&url)); |
| 372 ASSERT_STREQ("about:blank", url.spec().c_str()); | 372 ASSERT_STREQ("about:blank", url.spec().c_str()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 ASSERT_TRUE(window->ActivateTab(1)); | 406 ASSERT_TRUE(window->ActivateTab(1)); |
| 407 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 407 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 408 ASSERT_EQ(1, active_tab_index); | 408 ASSERT_EQ(1, active_tab_index); |
| 409 } | 409 } |
| 410 | 410 |
| 411 TEST_F(AutomationProxyTest2, GetTabTitle) { | 411 TEST_F(AutomationProxyTest2, GetTabTitle) { |
| 412 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 412 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 413 ASSERT_TRUE(window.get()); | 413 ASSERT_TRUE(window.get()); |
| 414 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 414 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 415 ASSERT_TRUE(tab.get()); | 415 ASSERT_TRUE(tab.get()); |
| 416 std::wstring title; | 416 string16 title; |
| 417 ASSERT_TRUE(tab->GetTabTitle(&title)); | 417 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 418 ASSERT_STREQ(L"title1.html", title.c_str()); | 418 ASSERT_EQ(ASCIIToUTF16("title1.html"), title); |
| 419 | 419 |
| 420 tab = window->GetTab(1); | 420 tab = window->GetTab(1); |
| 421 ASSERT_TRUE(tab.get()); | 421 ASSERT_TRUE(tab.get()); |
| 422 ASSERT_TRUE(tab->GetTabTitle(&title)); | 422 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 423 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 423 ASSERT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title); |
| 424 } | 424 } |
| 425 | 425 |
| 426 TEST_F(AutomationProxyTest, Cookies) { | 426 TEST_F(AutomationProxyTest, Cookies) { |
| 427 GURL url("http://mojo.jojo.google.com"); | 427 GURL url("http://mojo.jojo.google.com"); |
| 428 std::string value_result; | 428 std::string value_result; |
| 429 | 429 |
| 430 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 430 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 431 ASSERT_TRUE(window.get()); | 431 ASSERT_TRUE(window.get()); |
| 432 | 432 |
| 433 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 433 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 return jscript; | 540 return jscript; |
| 541 } | 541 } |
| 542 | 542 |
| 543 TEST_F(AutomationProxyTest4, StringValueIsEchoedByDomAutomationController) { | 543 TEST_F(AutomationProxyTest4, StringValueIsEchoedByDomAutomationController) { |
| 544 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 544 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 545 ASSERT_TRUE(window.get()); | 545 ASSERT_TRUE(window.get()); |
| 546 | 546 |
| 547 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 547 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 548 ASSERT_TRUE(tab.get()); | 548 ASSERT_TRUE(tab.get()); |
| 549 | 549 |
| 550 std::wstring expected(L"string"); | 550 string16 expected = ASCIIToUTF16("string"); |
| 551 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); | 551 string16 jscript = WideToUTF16Hack( |
| 552 std::wstring actual; | 552 CreateJSString(L"\"" + UTF16ToWideHack(expected) + L"\"")); |
| 553 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); | 553 string16 actual; |
| 554 ASSERT_STREQ(expected.c_str(), actual.c_str()); | 554 ASSERT_TRUE(tab->ExecuteAndExtractString(string16(), jscript, &actual)); |
| 555 ASSERT_EQ(expected, actual); |
| 555 } | 556 } |
| 556 | 557 |
| 557 std::wstring BooleanToString(bool bool_value) { | 558 std::wstring BooleanToString(bool bool_value) { |
| 558 Value* value = Value::CreateBooleanValue(bool_value); | 559 Value* value = Value::CreateBooleanValue(bool_value); |
| 559 std::string json_string; | 560 std::string json_string; |
| 560 JSONStringValueSerializer serializer(&json_string); | 561 JSONStringValueSerializer serializer(&json_string); |
| 561 serializer.Serialize(*value); | 562 serializer.Serialize(*value); |
| 562 return UTF8ToWide(json_string); | 563 return UTF8ToWide(json_string); |
| 563 } | 564 } |
| 564 | 565 |
| 565 TEST_F(AutomationProxyTest4, BooleanValueIsEchoedByDomAutomationController) { | 566 TEST_F(AutomationProxyTest4, BooleanValueIsEchoedByDomAutomationController) { |
| 566 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 567 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 567 ASSERT_TRUE(window.get()); | 568 ASSERT_TRUE(window.get()); |
| 568 | 569 |
| 569 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 570 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 570 ASSERT_TRUE(tab.get()); | 571 ASSERT_TRUE(tab.get()); |
| 571 | 572 |
| 572 bool expected = true; | 573 bool expected = true; |
| 573 std::wstring jscript = CreateJSString(BooleanToString(expected)); | 574 std::wstring jscript = CreateJSString(BooleanToString(expected)); |
| 574 bool actual = false; | 575 bool actual = false; |
| 575 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"", jscript, &actual)); | 576 ASSERT_TRUE(tab->ExecuteAndExtractBool(string16(), |
| 577 WideToUTF16Hack(jscript), |
| 578 &actual)); |
| 576 ASSERT_EQ(expected, actual); | 579 ASSERT_EQ(expected, actual); |
| 577 } | 580 } |
| 578 | 581 |
| 579 TEST_F(AutomationProxyTest4, NumberValueIsEchoedByDomAutomationController) { | 582 TEST_F(AutomationProxyTest4, NumberValueIsEchoedByDomAutomationController) { |
| 580 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 583 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 581 ASSERT_TRUE(window.get()); | 584 ASSERT_TRUE(window.get()); |
| 582 | 585 |
| 583 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 586 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 584 ASSERT_TRUE(tab.get()); | 587 ASSERT_TRUE(tab.get()); |
| 585 | 588 |
| 586 int expected = 1; | 589 int expected = 1; |
| 587 int actual = 0; | 590 int actual = 0; |
| 588 std::wstring expected_string; | 591 std::wstring expected_string; |
| 589 base::SStringPrintf(&expected_string, L"%d", expected); | 592 base::SStringPrintf(&expected_string, L"%d", expected); |
| 590 std::wstring jscript = CreateJSString(expected_string); | 593 std::wstring jscript = CreateJSString(expected_string); |
| 591 ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", jscript, &actual)); | 594 ASSERT_TRUE(tab->ExecuteAndExtractInt(string16(), |
| 595 WideToUTF16Hack(jscript), |
| 596 &actual)); |
| 592 ASSERT_EQ(expected, actual); | 597 ASSERT_EQ(expected, actual); |
| 593 } | 598 } |
| 594 | 599 |
| 595 // TODO(vibhor): Add a test for ExecuteAndExtractValue() for JSON Dictionary | 600 // TODO(vibhor): Add a test for ExecuteAndExtractValue() for JSON Dictionary |
| 596 // type value | 601 // type value |
| 597 | 602 |
| 598 class AutomationProxyTest3 : public UITest { | 603 class AutomationProxyTest3 : public UITest { |
| 599 protected: | 604 protected: |
| 600 AutomationProxyTest3() : UITest() { | 605 AutomationProxyTest3() : UITest() { |
| 601 document1_ = test_data_directory_; | 606 document1_ = test_data_directory_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 618 return jscript; | 623 return jscript; |
| 619 } | 624 } |
| 620 | 625 |
| 621 TEST_F(AutomationProxyTest3, FrameDocumentCanBeAccessed) { | 626 TEST_F(AutomationProxyTest3, FrameDocumentCanBeAccessed) { |
| 622 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 627 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 623 ASSERT_TRUE(window.get()); | 628 ASSERT_TRUE(window.get()); |
| 624 | 629 |
| 625 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 630 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 626 ASSERT_TRUE(tab.get()); | 631 ASSERT_TRUE(tab.get()); |
| 627 | 632 |
| 628 std::wstring actual; | 633 string16 actual; |
| 629 std::wstring xpath1 = L""; // top level frame | 634 string16 xpath1 = ASCIIToUTF16(""); // top level frame |
| 630 std::wstring jscript1 = CreateJSStringForDOMQuery(L"myinput"); | 635 std::wstring jscript1 = CreateJSStringForDOMQuery(L"myinput"); |
| 631 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); | 636 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath1, |
| 632 ASSERT_EQ(L"INPUT", actual); | 637 WideToUTF16Hack(jscript1), |
| 638 &actual)); |
| 639 ASSERT_EQ(ASCIIToUTF16("INPUT"), actual); |
| 633 | 640 |
| 634 std::wstring xpath2 = L"/html/body/iframe"; | 641 string16 xpath2 = ASCIIToUTF16("/html/body/iframe"); |
| 635 std::wstring jscript2 = CreateJSStringForDOMQuery(L"myspan"); | 642 std::wstring jscript2 = CreateJSStringForDOMQuery(L"myspan"); |
| 636 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath2, jscript2, &actual)); | 643 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath2, |
| 637 ASSERT_EQ(L"SPAN", actual); | 644 WideToUTF16Hack(jscript2), |
| 645 &actual)); |
| 646 ASSERT_EQ(ASCIIToUTF16("SPAN"), actual); |
| 638 | 647 |
| 639 std::wstring xpath3 = L"/html/body/iframe\n/html/body/iframe"; | 648 string16 xpath3 = ASCIIToUTF16("/html/body/iframe\n/html/body/iframe"); |
| 640 std::wstring jscript3 = CreateJSStringForDOMQuery(L"mydiv"); | 649 std::wstring jscript3 = CreateJSStringForDOMQuery(L"mydiv"); |
| 641 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath3, jscript3, &actual)); | 650 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath3, |
| 642 ASSERT_EQ(L"DIV", actual); | 651 WideToUTF16Hack(jscript3), |
| 652 &actual)); |
| 653 ASSERT_EQ(ASCIIToUTF16("DIV"), actual); |
| 643 } | 654 } |
| 644 | 655 |
| 645 // Flaky, http://crbug.com/70937 | 656 // Flaky, http://crbug.com/70937 |
| 646 TEST_F(AutomationProxyTest, FLAKY_BlockedPopupTest) { | 657 TEST_F(AutomationProxyTest, FLAKY_BlockedPopupTest) { |
| 647 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 658 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 648 ASSERT_TRUE(window.get()); | 659 ASSERT_TRUE(window.get()); |
| 649 | 660 |
| 650 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 661 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 651 ASSERT_TRUE(tab.get()); | 662 ASSERT_TRUE(tab.get()); |
| 652 | 663 |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); | 1522 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); |
| 1512 | 1523 |
| 1513 // Click OK. | 1524 // Click OK. |
| 1514 EXPECT_TRUE(automation()->ClickAppModalDialogButton( | 1525 EXPECT_TRUE(automation()->ClickAppModalDialogButton( |
| 1515 ui::MessageBoxFlags::DIALOGBUTTON_OK)); | 1526 ui::MessageBoxFlags::DIALOGBUTTON_OK)); |
| 1516 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 1527 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
| 1517 &button)); | 1528 &button)); |
| 1518 EXPECT_FALSE(modal_dialog_showing); | 1529 EXPECT_FALSE(modal_dialog_showing); |
| 1519 int result = -1; | 1530 int result = -1; |
| 1520 EXPECT_TRUE(tab->ExecuteAndExtractInt( | 1531 EXPECT_TRUE(tab->ExecuteAndExtractInt( |
| 1521 std::wstring(), | 1532 string16(), |
| 1522 L"window.domAutomationController.send(result);", &result)); | 1533 ASCIIToUTF16("window.domAutomationController.send(result);"), |
| 1534 &result)); |
| 1523 EXPECT_EQ(0, result); | 1535 EXPECT_EQ(0, result); |
| 1524 | 1536 |
| 1525 // Try again. | 1537 // Try again. |
| 1526 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 1538 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 1527 tab->NavigateToURL(GURL(content))); | 1539 tab->NavigateToURL(GURL(content))); |
| 1528 EXPECT_TRUE(automation()->WaitForAppModalDialog()); | 1540 EXPECT_TRUE(automation()->WaitForAppModalDialog()); |
| 1529 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 1541 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
| 1530 &button)); | 1542 &button)); |
| 1531 EXPECT_TRUE(modal_dialog_showing); | 1543 EXPECT_TRUE(modal_dialog_showing); |
| 1532 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_OK | | 1544 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_OK | |
| 1533 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); | 1545 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); |
| 1534 | 1546 |
| 1535 // Click Cancel this time. | 1547 // Click Cancel this time. |
| 1536 EXPECT_TRUE(automation()->ClickAppModalDialogButton( | 1548 EXPECT_TRUE(automation()->ClickAppModalDialogButton( |
| 1537 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL)); | 1549 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL)); |
| 1538 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 1550 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
| 1539 &button)); | 1551 &button)); |
| 1540 EXPECT_FALSE(modal_dialog_showing); | 1552 EXPECT_FALSE(modal_dialog_showing); |
| 1541 EXPECT_TRUE(tab->ExecuteAndExtractInt( | 1553 EXPECT_TRUE(tab->ExecuteAndExtractInt( |
| 1542 std::wstring(), | 1554 string16(), |
| 1543 L"window.domAutomationController.send(result);", &result)); | 1555 ASCIIToUTF16("window.domAutomationController.send(result);"), |
| 1556 &result)); |
| 1544 EXPECT_EQ(1, result); | 1557 EXPECT_EQ(1, result); |
| 1545 } | 1558 } |
| 1546 | 1559 |
| 1547 class AutomationProxyTest5 : public UITest { | 1560 class AutomationProxyTest5 : public UITest { |
| 1548 protected: | 1561 protected: |
| 1549 AutomationProxyTest5() { | 1562 AutomationProxyTest5() { |
| 1550 show_window_ = true; | 1563 show_window_ = true; |
| 1551 dom_automation_enabled_ = true; | 1564 dom_automation_enabled_ = true; |
| 1552 // We need to disable popup blocking to ensure that the RenderView | 1565 // We need to disable popup blocking to ensure that the RenderView |
| 1553 // instance for the popup actually closes. | 1566 // instance for the popup actually closes. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1564 | 1577 |
| 1565 FilePath filename(test_data_directory_); | 1578 FilePath filename(test_data_directory_); |
| 1566 filename = filename.AppendASCII("dom_automation_test_with_popup.html"); | 1579 filename = filename.AppendASCII("dom_automation_test_with_popup.html"); |
| 1567 | 1580 |
| 1568 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 1581 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 1569 tab->NavigateToURL(net::FilePathToFileURL(filename))); | 1582 tab->NavigateToURL(net::FilePathToFileURL(filename))); |
| 1570 | 1583 |
| 1571 // Allow some time for the popup to show up and close. | 1584 // Allow some time for the popup to show up and close. |
| 1572 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); | 1585 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); |
| 1573 | 1586 |
| 1574 std::wstring expected(L"string"); | 1587 string16 expected(ASCIIToUTF16("string")); |
| 1575 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); | 1588 std::wstring jscript = |
| 1576 std::wstring actual; | 1589 CreateJSString(L"\"" + UTF16ToWideHack(expected) + L"\""); |
| 1577 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); | 1590 string16 actual; |
| 1591 ASSERT_TRUE(tab->ExecuteAndExtractString(string16(), |
| 1592 WideToUTF16Hack(jscript), |
| 1593 &actual)); |
| 1578 ASSERT_EQ(expected, actual); | 1594 ASSERT_EQ(expected, actual); |
| 1579 } | 1595 } |
| 1580 | 1596 |
| 1581 class AutomationProxySnapshotTest : public UITest { | 1597 class AutomationProxySnapshotTest : public UITest { |
| 1582 protected: | 1598 protected: |
| 1583 AutomationProxySnapshotTest() { | 1599 AutomationProxySnapshotTest() { |
| 1584 dom_automation_enabled_ = true; | 1600 dom_automation_enabled_ = true; |
| 1585 if (!snapshot_dir_.CreateUniqueTempDir()) | 1601 if (!snapshot_dir_.CreateUniqueTempDir()) |
| 1586 ADD_FAILURE() << "Unable to create temporary directory"; | 1602 ADD_FAILURE() << "Unable to create temporary directory"; |
| 1587 else | 1603 else |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 int diff_pixels_count = 0; | 1772 int diff_pixels_count = 0; |
| 1757 for (int x = 0; x < img_size.width(); ++x) { | 1773 for (int x = 0; x < img_size.width(); ++x) { |
| 1758 for (int y = 0; y < img_size.height(); ++y) { | 1774 for (int y = 0; y < img_size.height(); ++y) { |
| 1759 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { | 1775 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { |
| 1760 ++diff_pixels_count; | 1776 ++diff_pixels_count; |
| 1761 } | 1777 } |
| 1762 } | 1778 } |
| 1763 } | 1779 } |
| 1764 ASSERT_EQ(diff_pixels_count, 0); | 1780 ASSERT_EQ(diff_pixels_count, 0); |
| 1765 } | 1781 } |
| OLD | NEW |