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 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 | 1377 |
1378 // TODO(port): Need to port autocomplete_edit_proxy.* first. | 1378 // TODO(port): Need to port autocomplete_edit_proxy.* first. |
1379 #if defined(OS_WIN) || defined(OS_LINUX) | 1379 #if defined(OS_WIN) || defined(OS_LINUX) |
1380 TEST_F(AutomationProxyTest, AutocompleteGetSetText) { | 1380 TEST_F(AutomationProxyTest, AutocompleteGetSetText) { |
1381 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 1381 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
1382 ASSERT_TRUE(browser.get()); | 1382 ASSERT_TRUE(browser.get()); |
1383 scoped_refptr<AutocompleteEditProxy> edit( | 1383 scoped_refptr<AutocompleteEditProxy> edit( |
1384 browser->GetAutocompleteEdit()); | 1384 browser->GetAutocompleteEdit()); |
1385 ASSERT_TRUE(edit.get()); | 1385 ASSERT_TRUE(edit.get()); |
1386 EXPECT_TRUE(edit->is_valid()); | 1386 EXPECT_TRUE(edit->is_valid()); |
1387 const std::wstring text_to_set = L"Lollerskates"; | 1387 const string16 text_to_set = ASCIIToUTF16("Lollerskates"); |
1388 std::wstring actual_text; | 1388 string16 actual_text; |
1389 EXPECT_TRUE(edit->SetText(text_to_set)); | 1389 EXPECT_TRUE(edit->SetText(text_to_set)); |
1390 EXPECT_TRUE(edit->GetText(&actual_text)); | 1390 EXPECT_TRUE(edit->GetText(&actual_text)); |
1391 EXPECT_EQ(text_to_set, actual_text); | 1391 EXPECT_EQ(text_to_set, actual_text); |
1392 scoped_refptr<AutocompleteEditProxy> edit2( | 1392 scoped_refptr<AutocompleteEditProxy> edit2( |
1393 browser->GetAutocompleteEdit()); | 1393 browser->GetAutocompleteEdit()); |
1394 EXPECT_TRUE(edit2->GetText(&actual_text)); | 1394 EXPECT_TRUE(edit2->GetText(&actual_text)); |
1395 EXPECT_EQ(text_to_set, actual_text); | 1395 EXPECT_EQ(text_to_set, actual_text); |
1396 } | 1396 } |
1397 | 1397 |
1398 TEST_F(AutomationProxyTest, AutocompleteParallelProxy) { | 1398 TEST_F(AutomationProxyTest, AutocompleteParallelProxy) { |
1399 scoped_refptr<BrowserProxy> browser1(automation()->GetBrowserWindow(0)); | 1399 scoped_refptr<BrowserProxy> browser1(automation()->GetBrowserWindow(0)); |
1400 ASSERT_TRUE(browser1.get()); | 1400 ASSERT_TRUE(browser1.get()); |
1401 scoped_refptr<AutocompleteEditProxy> edit1( | 1401 scoped_refptr<AutocompleteEditProxy> edit1( |
1402 browser1->GetAutocompleteEdit()); | 1402 browser1->GetAutocompleteEdit()); |
1403 ASSERT_TRUE(edit1.get()); | 1403 ASSERT_TRUE(edit1.get()); |
1404 EXPECT_TRUE(browser1->RunCommand(IDC_NEW_WINDOW)); | 1404 EXPECT_TRUE(browser1->RunCommand(IDC_NEW_WINDOW)); |
1405 scoped_refptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); | 1405 scoped_refptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); |
1406 ASSERT_TRUE(browser2.get()); | 1406 ASSERT_TRUE(browser2.get()); |
1407 scoped_refptr<AutocompleteEditProxy> edit2( | 1407 scoped_refptr<AutocompleteEditProxy> edit2( |
1408 browser2->GetAutocompleteEdit()); | 1408 browser2->GetAutocompleteEdit()); |
1409 ASSERT_TRUE(edit2.get()); | 1409 ASSERT_TRUE(edit2.get()); |
1410 EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored( | 1410 EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored( |
1411 TestTimeouts::action_max_timeout_ms())); | 1411 TestTimeouts::action_max_timeout_ms())); |
1412 const std::wstring text_to_set1 = L"Lollerskates"; | 1412 const string16 text_to_set1 = ASCIIToUTF16("Lollerskates"); |
1413 const std::wstring text_to_set2 = L"Roflcopter"; | 1413 const string16 text_to_set2 = ASCIIToUTF16("Roflcopter"); |
1414 std::wstring actual_text1, actual_text2; | 1414 string16 actual_text1, actual_text2; |
1415 EXPECT_TRUE(edit1->SetText(text_to_set1)); | 1415 EXPECT_TRUE(edit1->SetText(text_to_set1)); |
1416 EXPECT_TRUE(edit2->SetText(text_to_set2)); | 1416 EXPECT_TRUE(edit2->SetText(text_to_set2)); |
1417 EXPECT_TRUE(edit1->GetText(&actual_text1)); | 1417 EXPECT_TRUE(edit1->GetText(&actual_text1)); |
1418 EXPECT_TRUE(edit2->GetText(&actual_text2)); | 1418 EXPECT_TRUE(edit2->GetText(&actual_text2)); |
1419 EXPECT_EQ(text_to_set1, actual_text1); | 1419 EXPECT_EQ(text_to_set1, actual_text1); |
1420 EXPECT_EQ(text_to_set2, actual_text2); | 1420 EXPECT_EQ(text_to_set2, actual_text2); |
1421 } | 1421 } |
1422 | 1422 |
1423 #endif // defined(OS_WIN) || defined(OS_LINUX) | 1423 #endif // defined(OS_WIN) || defined(OS_LINUX) |
1424 | 1424 |
1425 #if defined(OS_MACOSX) | 1425 #if defined(OS_MACOSX) |
1426 // Disabled, http://crbug.com/48601. | 1426 // Disabled, http://crbug.com/48601. |
1427 #define AutocompleteMatchesTest DISABLED_AutocompleteMatchesTest | 1427 #define AutocompleteMatchesTest DISABLED_AutocompleteMatchesTest |
1428 #else | 1428 #else |
1429 // Flaky, http://crbug.com/19876. | 1429 // Flaky, http://crbug.com/19876. |
1430 #define AutocompleteMatchesTest FLAKY_AutocompleteMatchesTest | 1430 #define AutocompleteMatchesTest FLAKY_AutocompleteMatchesTest |
1431 #endif | 1431 #endif |
1432 TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { | 1432 TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { |
1433 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 1433 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
1434 ASSERT_TRUE(browser.get()); | 1434 ASSERT_TRUE(browser.get()); |
1435 scoped_refptr<AutocompleteEditProxy> edit( | 1435 scoped_refptr<AutocompleteEditProxy> edit( |
1436 browser->GetAutocompleteEdit()); | 1436 browser->GetAutocompleteEdit()); |
1437 ASSERT_TRUE(edit.get()); | 1437 ASSERT_TRUE(edit.get()); |
1438 EXPECT_TRUE(edit->is_valid()); | 1438 EXPECT_TRUE(edit->is_valid()); |
1439 EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); | 1439 EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); |
1440 ASSERT_TRUE(edit->WaitForFocus()); | 1440 ASSERT_TRUE(edit->WaitForFocus()); |
1441 EXPECT_TRUE(edit->SetText(L"Roflcopter")); | 1441 EXPECT_TRUE(edit->SetText(ASCIIToUTF16("Roflcopter"))); |
1442 EXPECT_TRUE(edit->WaitForQuery(TestTimeouts::action_max_timeout_ms())); | 1442 EXPECT_TRUE(edit->WaitForQuery(TestTimeouts::action_max_timeout_ms())); |
1443 bool query_in_progress; | 1443 bool query_in_progress; |
1444 EXPECT_TRUE(edit->IsQueryInProgress(&query_in_progress)); | 1444 EXPECT_TRUE(edit->IsQueryInProgress(&query_in_progress)); |
1445 EXPECT_FALSE(query_in_progress); | 1445 EXPECT_FALSE(query_in_progress); |
1446 std::vector<AutocompleteMatchData> matches; | 1446 std::vector<AutocompleteMatchData> matches; |
1447 EXPECT_TRUE(edit->GetAutocompleteMatches(&matches)); | 1447 EXPECT_TRUE(edit->GetAutocompleteMatches(&matches)); |
1448 EXPECT_FALSE(matches.empty()); | 1448 EXPECT_FALSE(matches.empty()); |
1449 } | 1449 } |
1450 | 1450 |
1451 // Flaky especially on Windows. See crbug.com/25039. | 1451 // Flaky especially on Windows. See crbug.com/25039. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); | 1506 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); |
1507 | 1507 |
1508 // Click OK. | 1508 // Click OK. |
1509 EXPECT_TRUE(automation()->ClickAppModalDialogButton( | 1509 EXPECT_TRUE(automation()->ClickAppModalDialogButton( |
1510 ui::MessageBoxFlags::DIALOGBUTTON_OK)); | 1510 ui::MessageBoxFlags::DIALOGBUTTON_OK)); |
1511 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 1511 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
1512 &button)); | 1512 &button)); |
1513 EXPECT_FALSE(modal_dialog_showing); | 1513 EXPECT_FALSE(modal_dialog_showing); |
1514 int result = -1; | 1514 int result = -1; |
1515 EXPECT_TRUE(tab->ExecuteAndExtractInt( | 1515 EXPECT_TRUE(tab->ExecuteAndExtractInt( |
1516 L"", L"window.domAutomationController.send(result);", &result)); | 1516 std::wstring(), |
| 1517 L"window.domAutomationController.send(result);", &result)); |
1517 EXPECT_EQ(0, result); | 1518 EXPECT_EQ(0, result); |
1518 | 1519 |
1519 // Try again. | 1520 // Try again. |
1520 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 1521 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
1521 tab->NavigateToURL(GURL(content))); | 1522 tab->NavigateToURL(GURL(content))); |
1522 EXPECT_TRUE(automation()->WaitForAppModalDialog()); | 1523 EXPECT_TRUE(automation()->WaitForAppModalDialog()); |
1523 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 1524 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
1524 &button)); | 1525 &button)); |
1525 EXPECT_TRUE(modal_dialog_showing); | 1526 EXPECT_TRUE(modal_dialog_showing); |
1526 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_OK | | 1527 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_OK | |
1527 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); | 1528 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button); |
1528 | 1529 |
1529 // Click Cancel this time. | 1530 // Click Cancel this time. |
1530 EXPECT_TRUE(automation()->ClickAppModalDialogButton( | 1531 EXPECT_TRUE(automation()->ClickAppModalDialogButton( |
1531 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL)); | 1532 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL)); |
1532 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 1533 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
1533 &button)); | 1534 &button)); |
1534 EXPECT_FALSE(modal_dialog_showing); | 1535 EXPECT_FALSE(modal_dialog_showing); |
1535 EXPECT_TRUE(tab->ExecuteAndExtractInt( | 1536 EXPECT_TRUE(tab->ExecuteAndExtractInt( |
1536 L"", L"window.domAutomationController.send(result);", &result)); | 1537 std::wstring(), |
| 1538 L"window.domAutomationController.send(result);", &result)); |
1537 EXPECT_EQ(1, result); | 1539 EXPECT_EQ(1, result); |
1538 } | 1540 } |
1539 | 1541 |
1540 class AutomationProxyTest5 : public UITest { | 1542 class AutomationProxyTest5 : public UITest { |
1541 protected: | 1543 protected: |
1542 AutomationProxyTest5() { | 1544 AutomationProxyTest5() { |
1543 show_window_ = true; | 1545 show_window_ = true; |
1544 dom_automation_enabled_ = true; | 1546 dom_automation_enabled_ = true; |
1545 // We need to disable popup blocking to ensure that the RenderView | 1547 // We need to disable popup blocking to ensure that the RenderView |
1546 // instance for the popup actually closes. | 1548 // instance for the popup actually closes. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 int diff_pixels_count = 0; | 1751 int diff_pixels_count = 0; |
1750 for (int x = 0; x < img_size.width(); ++x) { | 1752 for (int x = 0; x < img_size.width(); ++x) { |
1751 for (int y = 0; y < img_size.height(); ++y) { | 1753 for (int y = 0; y < img_size.height(); ++y) { |
1752 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { | 1754 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { |
1753 ++diff_pixels_count; | 1755 ++diff_pixels_count; |
1754 } | 1756 } |
1755 } | 1757 } |
1756 } | 1758 } |
1757 ASSERT_EQ(diff_pixels_count, 0); | 1759 ASSERT_EQ(diff_pixels_count, 0); |
1758 } | 1760 } |
OLD | NEW |