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