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

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

Issue 6012006: Revert 68944 - Revert "Add named testing interface." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 12 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) 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
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"
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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms)) 875 CreateFunctor(loop, &TimedMessageLoopRunner::QuitAfter, ms))
847 876
848 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT 877 template <typename T> T** ReceivePointer(scoped_ptr<T>& p) { // NOLINT
849 return reinterpret_cast<T**>(&p); 878 return reinterpret_cast<T**>(&p);
850 } 879 }
851 880
852 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT 881 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT
853 return reinterpret_cast<T**>(&p); 882 return reinterpret_cast<T**>(&p);
854 } 883 }
855 884
856 AutomationProxy* ExternalTabUITest::CreateAutomationProxy(int exec_timeout) { 885 // Replace the default automation proxy with our mock client.
857 mock_ = new ExternalTabUITestMockClient(exec_timeout); 886 ProxyLauncher* ExternalTabUITest::CreateProxyLauncher() {
858 return mock_; 887 return new ExternalTabUITestMockLauncher(&mock_);
859 } 888 }
860 889
861 // Create with specifying a url 890 // Create with specifying a url
862 // Flaky, http://crbug.com/32293 891 // Flaky, http://crbug.com/32293
863 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { 892 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) {
864 scoped_refptr<TabProxy> tab; 893 scoped_refptr<TabProxy> tab;
865 TimedMessageLoopRunner loop(MessageLoop::current()); 894 TimedMessageLoopRunner loop(MessageLoop::current());
866 ASSERT_THAT(mock_, testing::NotNull()); 895 ASSERT_THAT(mock_, testing::NotNull());
867 896
868 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) 897 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _))
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 int diff_pixels_count = 0; 1738 int diff_pixels_count = 0;
1710 for (int x = 0; x < img_size.width(); ++x) { 1739 for (int x = 0; x < img_size.width(); ++x) {
1711 for (int y = 0; y < img_size.height(); ++y) { 1740 for (int y = 0; y < img_size.height(); ++y) {
1712 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { 1741 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) {
1713 ++diff_pixels_count; 1742 ++diff_pixels_count;
1714 } 1743 }
1715 } 1744 }
1716 } 1745 }
1717 ASSERT_EQ(diff_pixels_count, 0); 1746 ASSERT_EQ(diff_pixels_count, 0);
1718 } 1747 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy_uitest.h ('k') | chrome/test/automation/proxy_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698