| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
| 17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "chrome/app/chrome_command_ids.h" | 20 #include "chrome/app/chrome_command_ids.h" |
| 21 #include "chrome/browser/net/url_request_slow_http_job.h" | 21 #include "chrome/browser/net/url_request_slow_http_job.h" |
| 22 #include "chrome/browser/ui/view_ids.h" | 22 #include "chrome/browser/ui/view_ids.h" |
| 23 #include "chrome/common/automation_messages.h" | 23 #include "chrome/common/automation_messages.h" |
| 24 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "chrome/test/automation/autocomplete_edit_proxy.h" | |
| 28 #include "chrome/test/automation/automation_proxy_uitest.h" | 27 #include "chrome/test/automation/automation_proxy_uitest.h" |
| 29 #include "chrome/test/automation/browser_proxy.h" | 28 #include "chrome/test/automation/browser_proxy.h" |
| 30 #include "chrome/test/automation/proxy_launcher.h" | 29 #include "chrome/test/automation/proxy_launcher.h" |
| 31 #include "chrome/test/automation/tab_proxy.h" | 30 #include "chrome/test/automation/tab_proxy.h" |
| 32 #include "chrome/test/automation/window_proxy.h" | 31 #include "chrome/test/automation/window_proxy.h" |
| 33 #include "chrome/test/ui/ui_test.h" | 32 #include "chrome/test/ui/ui_test.h" |
| 34 #include "chrome/test/ui_test_utils.h" | 33 #include "chrome/test/ui_test_utils.h" |
| 35 #include "content/common/json_value_serializer.h" | 34 #include "content/common/json_value_serializer.h" |
| 36 #include "net/base/host_port_pair.h" | 35 #include "net/base/host_port_pair.h" |
| 37 #include "net/base/net_util.h" | 36 #include "net/base/net_util.h" |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 .Times(1) | 1370 .Times(1) |
| 1372 .WillOnce(QUIT_LOOP_SOON(&loop, 500)); | 1371 .WillOnce(QUIT_LOOP_SOON(&loop, 500)); |
| 1373 | 1372 |
| 1374 mock_->CreateTabWithUrl(main_url); | 1373 mock_->CreateTabWithUrl(main_url); |
| 1375 loop.RunFor(TestTimeouts::action_max_timeout_ms()); | 1374 loop.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 1376 | 1375 |
| 1377 EXPECT_CALL(*mock_, HandleClosed(1)); | 1376 EXPECT_CALL(*mock_, HandleClosed(1)); |
| 1378 ::DestroyWindow(foo_host); | 1377 ::DestroyWindow(foo_host); |
| 1379 mock_->DestroyHostWindow(); | 1378 mock_->DestroyHostWindow(); |
| 1380 } | 1379 } |
| 1381 | |
| 1382 #endif // defined(OS_WIN) | 1380 #endif // defined(OS_WIN) |
| 1383 | 1381 |
| 1384 // TODO(port): Need to port autocomplete_edit_proxy.* first. | |
| 1385 #if defined(OS_WIN) || defined(OS_LINUX) | |
| 1386 TEST_F(AutomationProxyTest, AutocompleteGetSetText) { | |
| 1387 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
| 1388 ASSERT_TRUE(browser.get()); | |
| 1389 scoped_refptr<AutocompleteEditProxy> edit( | |
| 1390 browser->GetAutocompleteEdit()); | |
| 1391 ASSERT_TRUE(edit.get()); | |
| 1392 EXPECT_TRUE(edit->is_valid()); | |
| 1393 const string16 text_to_set = ASCIIToUTF16("Lollerskates"); | |
| 1394 string16 actual_text; | |
| 1395 EXPECT_TRUE(edit->SetText(text_to_set)); | |
| 1396 EXPECT_TRUE(edit->GetText(&actual_text)); | |
| 1397 EXPECT_EQ(text_to_set, actual_text); | |
| 1398 scoped_refptr<AutocompleteEditProxy> edit2( | |
| 1399 browser->GetAutocompleteEdit()); | |
| 1400 EXPECT_TRUE(edit2->GetText(&actual_text)); | |
| 1401 EXPECT_EQ(text_to_set, actual_text); | |
| 1402 } | |
| 1403 | |
| 1404 TEST_F(AutomationProxyTest, AutocompleteParallelProxy) { | |
| 1405 scoped_refptr<BrowserProxy> browser1(automation()->GetBrowserWindow(0)); | |
| 1406 ASSERT_TRUE(browser1.get()); | |
| 1407 scoped_refptr<AutocompleteEditProxy> edit1( | |
| 1408 browser1->GetAutocompleteEdit()); | |
| 1409 ASSERT_TRUE(edit1.get()); | |
| 1410 EXPECT_TRUE(browser1->RunCommand(IDC_NEW_WINDOW)); | |
| 1411 scoped_refptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); | |
| 1412 ASSERT_TRUE(browser2.get()); | |
| 1413 scoped_refptr<AutocompleteEditProxy> edit2( | |
| 1414 browser2->GetAutocompleteEdit()); | |
| 1415 ASSERT_TRUE(edit2.get()); | |
| 1416 EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored( | |
| 1417 TestTimeouts::action_max_timeout_ms())); | |
| 1418 const string16 text_to_set1 = ASCIIToUTF16("Lollerskates"); | |
| 1419 const string16 text_to_set2 = ASCIIToUTF16("Roflcopter"); | |
| 1420 string16 actual_text1, actual_text2; | |
| 1421 EXPECT_TRUE(edit1->SetText(text_to_set1)); | |
| 1422 EXPECT_TRUE(edit2->SetText(text_to_set2)); | |
| 1423 EXPECT_TRUE(edit1->GetText(&actual_text1)); | |
| 1424 EXPECT_TRUE(edit2->GetText(&actual_text2)); | |
| 1425 EXPECT_EQ(text_to_set1, actual_text1); | |
| 1426 EXPECT_EQ(text_to_set2, actual_text2); | |
| 1427 } | |
| 1428 | |
| 1429 #endif // defined(OS_WIN) || defined(OS_LINUX) | |
| 1430 | |
| 1431 #if defined(OS_MACOSX) | |
| 1432 // Disabled, http://crbug.com/48601. | |
| 1433 #define AutocompleteMatchesTest DISABLED_AutocompleteMatchesTest | |
| 1434 #else | |
| 1435 // Flaky, http://crbug.com/19876. | |
| 1436 #define AutocompleteMatchesTest FLAKY_AutocompleteMatchesTest | |
| 1437 #endif | |
| 1438 TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { | |
| 1439 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
| 1440 ASSERT_TRUE(browser.get()); | |
| 1441 scoped_refptr<AutocompleteEditProxy> edit( | |
| 1442 browser->GetAutocompleteEdit()); | |
| 1443 ASSERT_TRUE(edit.get()); | |
| 1444 EXPECT_TRUE(edit->is_valid()); | |
| 1445 EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); | |
| 1446 ASSERT_TRUE(edit->WaitForFocus()); | |
| 1447 EXPECT_TRUE(edit->SetText(ASCIIToUTF16("Roflcopter"))); | |
| 1448 EXPECT_TRUE(edit->WaitForQuery(TestTimeouts::action_max_timeout_ms())); | |
| 1449 bool query_in_progress; | |
| 1450 EXPECT_TRUE(edit->IsQueryInProgress(&query_in_progress)); | |
| 1451 EXPECT_FALSE(query_in_progress); | |
| 1452 std::vector<AutocompleteMatchData> matches; | |
| 1453 EXPECT_TRUE(edit->GetAutocompleteMatches(&matches)); | |
| 1454 EXPECT_FALSE(matches.empty()); | |
| 1455 } | |
| 1456 | |
| 1457 // Flaky especially on Windows. See crbug.com/25039. | 1382 // Flaky especially on Windows. See crbug.com/25039. |
| 1458 TEST_F(AutomationProxyTest, FLAKY_AppModalDialogTest) { | 1383 TEST_F(AutomationProxyTest, FLAKY_AppModalDialogTest) { |
| 1459 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 1384 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 1460 ASSERT_TRUE(browser.get()); | 1385 ASSERT_TRUE(browser.get()); |
| 1461 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | 1386 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
| 1462 ASSERT_TRUE(tab.get()); | 1387 ASSERT_TRUE(tab.get()); |
| 1463 | 1388 |
| 1464 bool modal_dialog_showing = false; | 1389 bool modal_dialog_showing = false; |
| 1465 ui::MessageBoxFlags::DialogButton button = | 1390 ui::MessageBoxFlags::DialogButton button = |
| 1466 ui::MessageBoxFlags::DIALOGBUTTON_NONE; | 1391 ui::MessageBoxFlags::DIALOGBUTTON_NONE; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 int diff_pixels_count = 0; | 1650 int diff_pixels_count = 0; |
| 1726 for (int x = 0; x < img_size.width(); ++x) { | 1651 for (int x = 0; x < img_size.width(); ++x) { |
| 1727 for (int y = 0; y < img_size.height(); ++y) { | 1652 for (int y = 0; y < img_size.height(); ++y) { |
| 1728 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { | 1653 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { |
| 1729 ++diff_pixels_count; | 1654 ++diff_pixels_count; |
| 1730 } | 1655 } |
| 1731 } | 1656 } |
| 1732 } | 1657 } |
| 1733 ASSERT_EQ(diff_pixels_count, 0); | 1658 ASSERT_EQ(diff_pixels_count, 0); |
| 1734 } | 1659 } |
| OLD | NEW |