OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 11 matching lines...) Loading... |
22 #include "chrome/browser/net/url_request_slow_http_job.h" | 22 #include "chrome/browser/net/url_request_slow_http_job.h" |
23 #include "chrome/browser/view_ids.h" | 23 #include "chrome/browser/view_ids.h" |
24 #include "chrome/common/automation_messages.h" | 24 #include "chrome/common/automation_messages.h" |
25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/json_value_serializer.h" | 27 #include "chrome/common/json_value_serializer.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "chrome/test/automation/autocomplete_edit_proxy.h" | 29 #include "chrome/test/automation/autocomplete_edit_proxy.h" |
30 #include "chrome/test/automation/automation_proxy_uitest.h" | 30 #include "chrome/test/automation/automation_proxy_uitest.h" |
31 #include "chrome/test/automation/browser_proxy.h" | 31 #include "chrome/test/automation/browser_proxy.h" |
32 #include "chrome/test/automation/proxy_launcher.h" | |
33 #include "chrome/test/automation/tab_proxy.h" | 32 #include "chrome/test/automation/tab_proxy.h" |
34 #include "chrome/test/automation/window_proxy.h" | 33 #include "chrome/test/automation/window_proxy.h" |
35 #include "chrome/test/ui_test_utils.h" | 34 #include "chrome/test/ui_test_utils.h" |
36 #include "chrome/test/ui/ui_test.h" | 35 #include "chrome/test/ui/ui_test.h" |
37 #include "gfx/codec/png_codec.h" | 36 #include "gfx/codec/png_codec.h" |
38 #include "gfx/rect.h" | 37 #include "gfx/rect.h" |
39 #include "net/base/net_util.h" | 38 #include "net/base/net_util.h" |
40 #include "net/test/test_server.h" | 39 #include "net/test/test_server.h" |
41 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | 40 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING |
42 #include "testing/gmock_mutant.h" | 41 #include "testing/gmock_mutant.h" |
43 #include "third_party/skia/include/core/SkBitmap.h" | 42 #include "third_party/skia/include/core/SkBitmap.h" |
44 #include "views/event.h" | 43 #include "views/event.h" |
45 | 44 |
46 using ui_test_utils::TimedMessageLoopRunner; | 45 using ui_test_utils::TimedMessageLoopRunner; |
47 using testing::CreateFunctor; | 46 using testing::CreateFunctor; |
48 using testing::StrEq; | 47 using testing::StrEq; |
49 using testing::_; | 48 using testing::_; |
50 | 49 |
51 // Replace the default automation proxy with our mock client. | |
52 class ExternalTabUITestMockLauncher : public ProxyLauncher { | |
53 public: | |
54 AutomationProxy* CreateAutomationProxy(int execution_timeout) const { | |
55 return new ExternalTabUITestMockClient(execution_timeout); | |
56 } | |
57 | |
58 void InitializeConnection(UITestBase* ui_test_base) const { | |
59 ui_test_base->LaunchBrowserAndServer(); | |
60 } | |
61 | |
62 std::string PrefixedChannelID() const { | |
63 return ""; | |
64 } | |
65 }; | |
66 | |
67 class AutomationProxyTest : public UITest { | 50 class AutomationProxyTest : public UITest { |
68 protected: | 51 protected: |
69 AutomationProxyTest() { | 52 AutomationProxyTest() { |
70 dom_automation_enabled_ = true; | 53 dom_automation_enabled_ = true; |
71 launch_arguments_.AppendSwitchASCII(switches::kLang, "en-US"); | 54 launch_arguments_.AppendSwitchASCII(switches::kLang, "en-US"); |
72 } | 55 } |
73 }; | 56 }; |
74 | 57 |
75 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { | 58 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { |
76 int window_count = 0; | 59 int window_count = 0; |
(...skipping 774 matching lines...) Loading... |
851 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms)) | 834 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms)) |
852 | 835 |
853 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT | 836 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT |
854 return reinterpret_cast<T**>(&p); | 837 return reinterpret_cast<T**>(&p); |
855 } | 838 } |
856 | 839 |
857 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT | 840 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT |
858 return reinterpret_cast<T**>(&p); | 841 return reinterpret_cast<T**>(&p); |
859 } | 842 } |
860 | 843 |
861 ProxyLauncher* ExternalTabUITest::CreateProxyLauncher() { | 844 AutomationProxy* ExternalTabUITest::CreateAutomationProxy(int exec_timeout) { |
862 return new ExternalTabUITestMockLauncher(); | 845 mock_ = new ExternalTabUITestMockClient(exec_timeout); |
| 846 return mock_; |
863 } | 847 } |
864 | 848 |
865 // Create with specifying a url | 849 // Create with specifying a url |
866 // Flaky, http://crbug.com/32293 | 850 // Flaky, http://crbug.com/32293 |
867 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { | 851 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { |
868 scoped_refptr<TabProxy> tab; | 852 scoped_refptr<TabProxy> tab; |
869 TimedMessageLoopRunner loop(MessageLoop::current()); | 853 TimedMessageLoopRunner loop(MessageLoop::current()); |
870 ASSERT_THAT(mock_, testing::NotNull()); | 854 ASSERT_THAT(mock_, testing::NotNull()); |
871 | 855 |
872 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) | 856 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) |
(...skipping 839 matching lines...) Loading... |
1712 int diff_pixels_count = 0; | 1696 int diff_pixels_count = 0; |
1713 for (int x = 0; x < img_size.width(); ++x) { | 1697 for (int x = 0; x < img_size.width(); ++x) { |
1714 for (int y = 0; y < img_size.height(); ++y) { | 1698 for (int y = 0; y < img_size.height(); ++y) { |
1715 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { | 1699 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { |
1716 ++diff_pixels_count; | 1700 ++diff_pixels_count; |
1717 } | 1701 } |
1718 } | 1702 } |
1719 } | 1703 } |
1720 ASSERT_EQ(diff_pixels_count, 0); | 1704 ASSERT_EQ(diff_pixels_count, 0); |
1721 } | 1705 } |
OLD | NEW |