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...) Expand all 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" | |
32 #include "chrome/test/automation/tab_proxy.h" | 33 #include "chrome/test/automation/tab_proxy.h" |
33 #include "chrome/test/automation/window_proxy.h" | 34 #include "chrome/test/automation/window_proxy.h" |
34 #include "chrome/test/ui_test_utils.h" | 35 #include "chrome/test/ui_test_utils.h" |
35 #include "chrome/test/ui/ui_test.h" | 36 #include "chrome/test/ui/ui_test.h" |
36 #include "gfx/codec/png_codec.h" | 37 #include "gfx/codec/png_codec.h" |
37 #include "gfx/rect.h" | 38 #include "gfx/rect.h" |
38 #include "net/base/net_util.h" | 39 #include "net/base/net_util.h" |
39 #include "net/test/test_server.h" | 40 #include "net/test/test_server.h" |
40 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | 41 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING |
41 #include "testing/gmock_mutant.h" | 42 #include "testing/gmock_mutant.h" |
42 #include "third_party/skia/include/core/SkBitmap.h" | 43 #include "third_party/skia/include/core/SkBitmap.h" |
43 #include "views/event.h" | 44 #include "views/event.h" |
44 | 45 |
45 using ui_test_utils::TimedMessageLoopRunner; | 46 using ui_test_utils::TimedMessageLoopRunner; |
46 using testing::CreateFunctor; | 47 using testing::CreateFunctor; |
47 using testing::StrEq; | 48 using testing::StrEq; |
48 using testing::_; | 49 using testing::_; |
49 | 50 |
51 // Replace the default automation proxy with our mock client. | |
52 class ExternalTabUITestMockLauncher : public ProxyLauncher { | |
53 public: | |
54 explicit ExternalTabUITestMockLauncher(ExternalTabUITestMockClient **mock) | |
55 : mock_(mock) { | |
56 channel_id_ = AutomationProxy::GenerateChannelID(); | |
57 } | |
58 | |
59 AutomationProxy* CreateAutomationProxy(int execution_timeout) const { | |
60 *mock_ = new ExternalTabUITestMockClient(execution_timeout); | |
61 (*mock_)->InitializeChannel(channel_id_, false); | |
62 return *mock_; | |
63 } | |
64 | |
65 void InitializeConnection(UITestBase* ui_test_base) const { | |
66 ui_test_base->LaunchBrowserAndServer(); | |
67 } | |
68 | |
69 std::string PrefixedChannelID() const { | |
70 return channel_id_; | |
71 } | |
72 | |
73 private: | |
74 ExternalTabUITestMockClient **mock_; | |
75 std::string channel_id_; // Channel id of automation proxy. | |
76 }; | |
77 | |
50 class AutomationProxyTest : public UITest { | 78 class AutomationProxyTest : public UITest { |
51 protected: | 79 protected: |
52 AutomationProxyTest() { | 80 AutomationProxyTest() { |
53 dom_automation_enabled_ = true; | 81 dom_automation_enabled_ = true; |
54 launch_arguments_.AppendSwitchASCII(switches::kLang, "en-US"); | 82 launch_arguments_.AppendSwitchASCII(switches::kLang, "en-US"); |
55 } | 83 } |
56 }; | 84 }; |
57 | 85 |
58 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { | 86 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { |
59 int window_count = 0; | 87 int window_count = 0; |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms)) | 862 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms)) |
835 | 863 |
836 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT | 864 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT |
837 return reinterpret_cast<T**>(&p); | 865 return reinterpret_cast<T**>(&p); |
838 } | 866 } |
839 | 867 |
840 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT | 868 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT |
841 return reinterpret_cast<T**>(&p); | 869 return reinterpret_cast<T**>(&p); |
842 } | 870 } |
843 | 871 |
844 AutomationProxy* ExternalTabUITest::CreateAutomationProxy(int exec_timeout) { | 872 ProxyLauncher* ExternalTabUITest::CreateProxyLauncher() { |
845 mock_ = new ExternalTabUITestMockClient(exec_timeout); | 873 return new ExternalTabUITestMockLauncher(&mock_); |
amit
2010/11/19 18:27:10
Ugg! Is there any better way to do this?
It's not
dtu
2010/11/19 19:37:08
Good idea. Even if it's not ideal it's better than
dtu
2010/11/24 06:29:23
Actually, it's not working, which i think is becau
| |
846 return mock_; | |
847 } | 874 } |
848 | 875 |
849 // Create with specifying a url | 876 // Create with specifying a url |
850 // Flaky, http://crbug.com/32293 | 877 // Flaky, http://crbug.com/32293 |
851 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { | 878 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { |
852 scoped_refptr<TabProxy> tab; | 879 scoped_refptr<TabProxy> tab; |
853 TimedMessageLoopRunner loop(MessageLoop::current()); | 880 TimedMessageLoopRunner loop(MessageLoop::current()); |
854 ASSERT_THAT(mock_, testing::NotNull()); | 881 ASSERT_THAT(mock_, testing::NotNull()); |
855 | 882 |
856 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) | 883 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1696 int diff_pixels_count = 0; | 1723 int diff_pixels_count = 0; |
1697 for (int x = 0; x < img_size.width(); ++x) { | 1724 for (int x = 0; x < img_size.width(); ++x) { |
1698 for (int y = 0; y < img_size.height(); ++y) { | 1725 for (int y = 0; y < img_size.height(); ++y) { |
1699 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { | 1726 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { |
1700 ++diff_pixels_count; | 1727 ++diff_pixels_count; |
1701 } | 1728 } |
1702 } | 1729 } |
1703 } | 1730 } |
1704 ASSERT_EQ(diff_pixels_count, 0); | 1731 ASSERT_EQ(diff_pixels_count, 0); |
1705 } | 1732 } |
OLD | NEW |