Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/test/automation/automation_proxy_uitest.cc

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "app/message_box_flags.h"
9 #include "base/command_line.h" 8 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
11 #include "base/file_path.h" 10 #include "base/file_path.h"
12 #include "base/file_util.h" 11 #include "base/file_util.h"
13 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
14 #include "base/scoped_temp_dir.h" 13 #include "base/scoped_temp_dir.h"
15 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
16 #include "base/string_util.h" 15 #include "base/string_util.h"
17 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
18 #include "base/sys_info.h" 17 #include "base/sys_info.h"
(...skipping 16 matching lines...) Expand all
35 #include "chrome/test/automation/window_proxy.h" 34 #include "chrome/test/automation/window_proxy.h"
36 #include "chrome/test/ui_test_utils.h" 35 #include "chrome/test/ui_test_utils.h"
37 #include "chrome/test/ui/ui_test.h" 36 #include "chrome/test/ui/ui_test.h"
38 #include "gfx/codec/png_codec.h" 37 #include "gfx/codec/png_codec.h"
39 #include "gfx/rect.h" 38 #include "gfx/rect.h"
40 #include "net/base/net_util.h" 39 #include "net/base/net_util.h"
41 #include "net/test/test_server.h" 40 #include "net/test/test_server.h"
42 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING 41 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING
43 #include "testing/gmock_mutant.h" 42 #include "testing/gmock_mutant.h"
44 #include "third_party/skia/include/core/SkBitmap.h" 43 #include "third_party/skia/include/core/SkBitmap.h"
44 #include "ui/base/message_box_flags.h"
45 #include "views/event.h" 45 #include "views/event.h"
46 46
47 using ui_test_utils::TimedMessageLoopRunner; 47 using ui_test_utils::TimedMessageLoopRunner;
48 using testing::CreateFunctor; 48 using testing::CreateFunctor;
49 using testing::StrEq; 49 using testing::StrEq;
50 using testing::_; 50 using testing::_;
51 51
52 52
53 // Replace the default automation proxy with our mock client. 53 // Replace the default automation proxy with our mock client.
54 class ExternalTabUITestMockLauncher : public ProxyLauncher { 54 class ExternalTabUITestMockLauncher : public ProxyLauncher {
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 } 1448 }
1449 1449
1450 // Flaky especially on Windows. See crbug.com/25039. 1450 // Flaky especially on Windows. See crbug.com/25039.
1451 TEST_F(AutomationProxyTest, FLAKY_AppModalDialogTest) { 1451 TEST_F(AutomationProxyTest, FLAKY_AppModalDialogTest) {
1452 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 1452 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
1453 ASSERT_TRUE(browser.get()); 1453 ASSERT_TRUE(browser.get());
1454 scoped_refptr<TabProxy> tab(browser->GetTab(0)); 1454 scoped_refptr<TabProxy> tab(browser->GetTab(0));
1455 ASSERT_TRUE(tab.get()); 1455 ASSERT_TRUE(tab.get());
1456 1456
1457 bool modal_dialog_showing = false; 1457 bool modal_dialog_showing = false;
1458 MessageBoxFlags::DialogButton button = MessageBoxFlags::DIALOGBUTTON_NONE; 1458 ui::MessageBoxFlags::DialogButton button =
1459 ui::MessageBoxFlags::DIALOGBUTTON_NONE;
1459 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1460 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1460 &button)); 1461 &button));
1461 EXPECT_FALSE(modal_dialog_showing); 1462 EXPECT_FALSE(modal_dialog_showing);
1462 EXPECT_EQ(MessageBoxFlags::DIALOGBUTTON_NONE, button); 1463 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_NONE, button);
1463 1464
1464 // Show a simple alert. 1465 // Show a simple alert.
1465 std::string content = 1466 std::string content =
1466 "data:text/html,<html><head><script>function onload() {" 1467 "data:text/html,<html><head><script>function onload() {"
1467 "setTimeout(\"alert('hello');\", 1000); }</script></head>" 1468 "setTimeout(\"alert('hello');\", 1000); }</script></head>"
1468 "<body onload='onload()'></body></html>"; 1469 "<body onload='onload()'></body></html>";
1469 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 1470 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
1470 tab->NavigateToURL(GURL(content))); 1471 tab->NavigateToURL(GURL(content)));
1471 EXPECT_TRUE(automation()->WaitForAppModalDialog()); 1472 EXPECT_TRUE(automation()->WaitForAppModalDialog());
1472 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1473 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1473 &button)); 1474 &button));
1474 EXPECT_TRUE(modal_dialog_showing); 1475 EXPECT_TRUE(modal_dialog_showing);
1475 EXPECT_EQ(MessageBoxFlags::DIALOGBUTTON_OK, button); 1476 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_OK, button);
1476 1477
1477 // Test that clicking missing button fails graciously and does not close the 1478 // Test that clicking missing button fails graciously and does not close the
1478 // dialog. 1479 // dialog.
1479 EXPECT_FALSE(automation()->ClickAppModalDialogButton( 1480 EXPECT_FALSE(automation()->ClickAppModalDialogButton(
1480 MessageBoxFlags::DIALOGBUTTON_CANCEL)); 1481 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL));
1481 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1482 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1482 &button)); 1483 &button));
1483 EXPECT_TRUE(modal_dialog_showing); 1484 EXPECT_TRUE(modal_dialog_showing);
1484 1485
1485 // Now click OK, that should close the dialog. 1486 // Now click OK, that should close the dialog.
1486 EXPECT_TRUE(automation()->ClickAppModalDialogButton( 1487 EXPECT_TRUE(automation()->ClickAppModalDialogButton(
1487 MessageBoxFlags::DIALOGBUTTON_OK)); 1488 ui::MessageBoxFlags::DIALOGBUTTON_OK));
1488 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1489 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1489 &button)); 1490 &button));
1490 EXPECT_FALSE(modal_dialog_showing); 1491 EXPECT_FALSE(modal_dialog_showing);
1491 1492
1492 // Show a confirm dialog. 1493 // Show a confirm dialog.
1493 content = 1494 content =
1494 "data:text/html,<html><head><script>var result = -1; function onload() {" 1495 "data:text/html,<html><head><script>var result = -1; function onload() {"
1495 "setTimeout(\"result = confirm('hello') ? 0 : 1;\", 1000);} </script>" 1496 "setTimeout(\"result = confirm('hello') ? 0 : 1;\", 1000);} </script>"
1496 "</head><body onload='onload()'></body></html>"; 1497 "</head><body onload='onload()'></body></html>";
1497 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 1498 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
1498 tab->NavigateToURL(GURL(content))); 1499 tab->NavigateToURL(GURL(content)));
1499 EXPECT_TRUE(automation()->WaitForAppModalDialog()); 1500 EXPECT_TRUE(automation()->WaitForAppModalDialog());
1500 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1501 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1501 &button)); 1502 &button));
1502 EXPECT_TRUE(modal_dialog_showing); 1503 EXPECT_TRUE(modal_dialog_showing);
1503 EXPECT_EQ(MessageBoxFlags::DIALOGBUTTON_OK | 1504 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_OK |
1504 MessageBoxFlags::DIALOGBUTTON_CANCEL, button); 1505 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button);
1505 1506
1506 // Click OK. 1507 // Click OK.
1507 EXPECT_TRUE(automation()->ClickAppModalDialogButton( 1508 EXPECT_TRUE(automation()->ClickAppModalDialogButton(
1508 MessageBoxFlags::DIALOGBUTTON_OK)); 1509 ui::MessageBoxFlags::DIALOGBUTTON_OK));
1509 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1510 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1510 &button)); 1511 &button));
1511 EXPECT_FALSE(modal_dialog_showing); 1512 EXPECT_FALSE(modal_dialog_showing);
1512 int result = -1; 1513 int result = -1;
1513 EXPECT_TRUE(tab->ExecuteAndExtractInt( 1514 EXPECT_TRUE(tab->ExecuteAndExtractInt(
1514 L"", L"window.domAutomationController.send(result);", &result)); 1515 L"", L"window.domAutomationController.send(result);", &result));
1515 EXPECT_EQ(0, result); 1516 EXPECT_EQ(0, result);
1516 1517
1517 // Try again. 1518 // Try again.
1518 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 1519 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
1519 tab->NavigateToURL(GURL(content))); 1520 tab->NavigateToURL(GURL(content)));
1520 EXPECT_TRUE(automation()->WaitForAppModalDialog()); 1521 EXPECT_TRUE(automation()->WaitForAppModalDialog());
1521 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1522 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1522 &button)); 1523 &button));
1523 EXPECT_TRUE(modal_dialog_showing); 1524 EXPECT_TRUE(modal_dialog_showing);
1524 EXPECT_EQ(MessageBoxFlags::DIALOGBUTTON_OK | 1525 EXPECT_EQ(ui::MessageBoxFlags::DIALOGBUTTON_OK |
1525 MessageBoxFlags::DIALOGBUTTON_CANCEL, button); 1526 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, button);
1526 1527
1527 // Click Cancel this time. 1528 // Click Cancel this time.
1528 EXPECT_TRUE(automation()->ClickAppModalDialogButton( 1529 EXPECT_TRUE(automation()->ClickAppModalDialogButton(
1529 MessageBoxFlags::DIALOGBUTTON_CANCEL)); 1530 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL));
1530 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, 1531 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
1531 &button)); 1532 &button));
1532 EXPECT_FALSE(modal_dialog_showing); 1533 EXPECT_FALSE(modal_dialog_showing);
1533 EXPECT_TRUE(tab->ExecuteAndExtractInt( 1534 EXPECT_TRUE(tab->ExecuteAndExtractInt(
1534 L"", L"window.domAutomationController.send(result);", &result)); 1535 L"", L"window.domAutomationController.send(result);", &result));
1535 EXPECT_EQ(1, result); 1536 EXPECT_EQ(1, result);
1536 } 1537 }
1537 1538
1538 class AutomationProxyTest5 : public UITest { 1539 class AutomationProxyTest5 : public UITest {
1539 protected: 1540 protected:
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 int diff_pixels_count = 0; 1748 int diff_pixels_count = 0;
1748 for (int x = 0; x < img_size.width(); ++x) { 1749 for (int x = 0; x < img_size.width(); ++x) {
1749 for (int y = 0; y < img_size.height(); ++y) { 1750 for (int y = 0; y < img_size.height(); ++y) {
1750 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { 1751 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) {
1751 ++diff_pixels_count; 1752 ++diff_pixels_count;
1752 } 1753 }
1753 } 1754 }
1754 } 1755 }
1755 ASSERT_EQ(diff_pixels_count, 0); 1756 ASSERT_EQ(diff_pixels_count, 0);
1756 } 1757 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy.h ('k') | chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698