| 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 |
| 52 // Replace the default automation proxy with our mock client. |
| 53 class ExternalTabUITestMockLauncher : public ProxyLauncher { |
| 54 public: |
| 55 explicit ExternalTabUITestMockLauncher(ExternalTabUITestMockClient **mock) |
| 56 : mock_(mock) { |
| 57 channel_id_ = AutomationProxy::GenerateChannelID(); |
| 58 } |
| 59 |
| 60 AutomationProxy* CreateAutomationProxy(int execution_timeout) { |
| 61 *mock_ = new ExternalTabUITestMockClient(execution_timeout); |
| 62 (*mock_)->InitializeChannel(channel_id_, false); |
| 63 return *mock_; |
| 64 } |
| 65 |
| 66 void InitializeConnection(UITestBase* ui_test_base) const { |
| 67 ui_test_base->LaunchBrowserAndServer(); |
| 68 } |
| 69 |
| 70 std::string PrefixedChannelID() const { |
| 71 return channel_id_; |
| 72 } |
| 73 |
| 74 private: |
| 75 ExternalTabUITestMockClient **mock_; |
| 76 std::string channel_id_; // Channel id of automation proxy. |
| 77 }; |
| 78 |
| 50 class AutomationProxyTest : public UITest { | 79 class AutomationProxyTest : public UITest { |
| 51 protected: | 80 protected: |
| 52 AutomationProxyTest() { | 81 AutomationProxyTest() { |
| 53 dom_automation_enabled_ = true; | 82 dom_automation_enabled_ = true; |
| 54 launch_arguments_.AppendSwitchASCII(switches::kLang, "en-US"); | 83 launch_arguments_.AppendSwitchASCII(switches::kLang, "en-US"); |
| 55 } | 84 } |
| 56 }; | 85 }; |
| 57 | 86 |
| 58 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { | 87 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { |
| 59 int window_count = 0; | 88 int window_count = 0; |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms)) | 863 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms)) |
| 835 | 864 |
| 836 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT | 865 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT |
| 837 return reinterpret_cast<T**>(&p); | 866 return reinterpret_cast<T**>(&p); |
| 838 } | 867 } |
| 839 | 868 |
| 840 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT | 869 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT |
| 841 return reinterpret_cast<T**>(&p); | 870 return reinterpret_cast<T**>(&p); |
| 842 } | 871 } |
| 843 | 872 |
| 844 AutomationProxy* ExternalTabUITest::CreateAutomationProxy(int exec_timeout) { | 873 // Replace the default automation proxy with our mock client. |
| 845 mock_ = new ExternalTabUITestMockClient(exec_timeout); | 874 ProxyLauncher* ExternalTabUITest::CreateProxyLauncher() { |
| 846 return mock_; | 875 return new ExternalTabUITestMockLauncher(&mock_); |
| 847 } | 876 } |
| 848 | 877 |
| 849 // Create with specifying a url | 878 // Create with specifying a url |
| 850 // Flaky, http://crbug.com/32293 | 879 // Flaky, http://crbug.com/32293 |
| 851 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { | 880 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { |
| 852 scoped_refptr<TabProxy> tab; | 881 scoped_refptr<TabProxy> tab; |
| 853 TimedMessageLoopRunner loop(MessageLoop::current()); | 882 TimedMessageLoopRunner loop(MessageLoop::current()); |
| 854 ASSERT_THAT(mock_, testing::NotNull()); | 883 ASSERT_THAT(mock_, testing::NotNull()); |
| 855 | 884 |
| 856 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) | 885 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 int diff_pixels_count = 0; | 1726 int diff_pixels_count = 0; |
| 1698 for (int x = 0; x < img_size.width(); ++x) { | 1727 for (int x = 0; x < img_size.width(); ++x) { |
| 1699 for (int y = 0; y < img_size.height(); ++y) { | 1728 for (int y = 0; y < img_size.height(); ++y) { |
| 1700 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { | 1729 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { |
| 1701 ++diff_pixels_count; | 1730 ++diff_pixels_count; |
| 1702 } | 1731 } |
| 1703 } | 1732 } |
| 1704 } | 1733 } |
| 1705 ASSERT_EQ(diff_pixels_count, 0); | 1734 ASSERT_EQ(diff_pixels_count, 0); |
| 1706 } | 1735 } |
| OLD | NEW |