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

Side by Side Diff: chrome/browser/automation/automation_tab_helper_browsertest.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/automation/automation_tab_helper.h" 11 #include "chrome/browser/automation/automation_tab_helper.h"
12 #include "chrome/browser/automation/mock_tab_event_observer.h" 12 #include "chrome/browser/automation/mock_tab_event_observer.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
17 #include "chrome/test/in_process_browser_test.h" 18 #include "chrome/test/in_process_browser_test.h"
18 #include "chrome/test/ui_test_utils.h" 19 #include "chrome/test/ui_test_utils.h"
19 #include "content/browser/renderer_host/render_view_host.h" 20 #include "content/browser/renderer_host/render_view_host.h"
20 #include "content/browser/tab_contents/tab_contents.h" 21 #include "content/browser/tab_contents/tab_contents.h"
21 #include "content/common/notification_details.h" 22 #include "content/common/notification_details.h"
22 #include "content/common/notification_observer.h" 23 #include "content/common/notification_observer.h"
23 #include "content/common/notification_registrar.h" 24 #include "content/common/notification_registrar.h"
24 #include "content/common/notification_service.h" 25 #include "content/common/notification_service.h"
25 #include "content/common/notification_source.h" 26 #include "content/common/notification_source.h"
26 #include "content/common/notification_type.h"
27 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using testing::_; 31 using testing::_;
32 32
33 class MockNotificationObserver : public NotificationObserver { 33 class MockNotificationObserver : public NotificationObserver {
34 public: 34 public:
35 MockNotificationObserver() { } 35 MockNotificationObserver() { }
36 virtual ~MockNotificationObserver() { } 36 virtual ~MockNotificationObserver() { }
37 37
38 MOCK_METHOD3(Observe, void(NotificationType type, 38 MOCK_METHOD3(Observe, void(int type,
39 const NotificationSource& source, 39 const NotificationSource& source,
40 const NotificationDetails& details)); 40 const NotificationDetails& details));
41 41
42 void Register(NotificationType type, const NotificationSource& source) { 42 void Register(int type, const NotificationSource& source) {
43 registrar_.Add(this, type, source); 43 registrar_.Add(this, type, source);
44 } 44 }
45 45
46 private: 46 private:
47 NotificationRegistrar registrar_; 47 NotificationRegistrar registrar_;
48 48
49 DISALLOW_COPY_AND_ASSIGN(MockNotificationObserver); 49 DISALLOW_COPY_AND_ASSIGN(MockNotificationObserver);
50 }; 50 };
51 51
52 class AutomationTabHelperBrowserTest : public InProcessBrowserTest { 52 class AutomationTabHelperBrowserTest : public InProcessBrowserTest {
53 public: 53 public:
54 AutomationTabHelperBrowserTest() { 54 AutomationTabHelperBrowserTest() {
55 EnableDOMAutomation(); 55 EnableDOMAutomation();
56 } 56 }
57 virtual ~AutomationTabHelperBrowserTest() { } 57 virtual ~AutomationTabHelperBrowserTest() { }
58 58
59 void SetUpInProcessBrowserTestFixture() { 59 void SetUpInProcessBrowserTestFixture() {
60 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); 60 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
61 test_data_dir_ = test_data_dir_.AppendASCII("automation"); 61 test_data_dir_ = test_data_dir_.AppendASCII("automation");
62 } 62 }
63 63
64 // Add default expectations for a client redirection initiated by script, 64 // Add default expectations for a client redirection initiated by script,
65 // and quit the message loop when the redirect has completed. This expects 65 // and quit the message loop when the redirect has completed. This expects
66 // that the tab receives news of the redirect before the script returns. 66 // that the tab receives news of the redirect before the script returns.
67 void ExpectClientRedirectAndBreak( 67 void ExpectClientRedirectAndBreak(
68 MockTabEventObserver* mock_tab_observer, 68 MockTabEventObserver* mock_tab_observer,
69 MockNotificationObserver* mock_notification_observer) { 69 MockNotificationObserver* mock_notification_observer) {
70 mock_notification_observer->Register( 70 mock_notification_observer->Register(
71 NotificationType::DOM_OPERATION_RESPONSE, 71 chrome::NOTIFICATION_DOM_OPERATION_RESPONSE,
72 NotificationService::AllSources()); 72 NotificationService::AllSources());
73 73
74 testing::InSequence expect_in_sequence; 74 testing::InSequence expect_in_sequence;
75 EXPECT_CALL(*mock_tab_observer, OnFirstPendingLoad(_)); 75 EXPECT_CALL(*mock_tab_observer, OnFirstPendingLoad(_));
76 EXPECT_CALL(*mock_notification_observer, Observe( 76 EXPECT_CALL(*mock_notification_observer, Observe(
77 testing::Eq(NotificationType::DOM_OPERATION_RESPONSE), _, _)); 77 testing::Eq(chrome::NOTIFICATION_DOM_OPERATION_RESPONSE), _, _));
78 EXPECT_CALL(*mock_tab_observer, OnNoMorePendingLoads(_)) 78 EXPECT_CALL(*mock_tab_observer, OnNoMorePendingLoads(_))
79 .WillOnce(testing::InvokeWithoutArgs( 79 .WillOnce(testing::InvokeWithoutArgs(
80 MessageLoopForUI::current(), &MessageLoop::Quit)); 80 MessageLoopForUI::current(), &MessageLoop::Quit));
81 } 81 }
82 82
83 // Executes javascript to execute a given test case found in the current 83 // Executes javascript to execute a given test case found in the current
84 // page's script. If |wait_for_response| is true, this method will not 84 // page's script. If |wait_for_response| is true, this method will not
85 // return until the javascript has been executed. 85 // return until the javascript has been executed.
86 // Use with [ASSERT|EXPECT]_NO_FATAL_FAILURE. 86 // Use with [ASSERT|EXPECT]_NO_FATAL_FAILURE.
87 void RunTestCaseInJavaScript(int test_case_number, bool wait_for_response) { 87 void RunTestCaseInJavaScript(int test_case_number, bool wait_for_response) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 174 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
175 browser(), 175 browser(),
176 net::FilePathToFileURL(test_data_dir_.AppendASCII("meta_redirect.html")), 176 net::FilePathToFileURL(test_data_dir_.AppendASCII("meta_redirect.html")),
177 2); 177 2);
178 } 178 }
179 179
180 // Tests that the load stop event occurs after the window onload handler. 180 // Tests that the load stop event occurs after the window onload handler.
181 IN_PROC_BROWSER_TEST_F(AutomationTabHelperBrowserTest, 181 IN_PROC_BROWSER_TEST_F(AutomationTabHelperBrowserTest,
182 LoadStopComesAfterOnLoad) { 182 LoadStopComesAfterOnLoad) {
183 MockNotificationObserver mock_notification_observer; 183 MockNotificationObserver mock_notification_observer;
184 mock_notification_observer.Register(NotificationType::DOM_OPERATION_RESPONSE, 184 mock_notification_observer.Register(
185 NotificationService::AllSources()); 185 chrome::NOTIFICATION_DOM_OPERATION_RESPONSE,
186 NotificationService::AllSources());
186 MockTabEventObserver mock_tab_observer(tab_helper()); 187 MockTabEventObserver mock_tab_observer(tab_helper());
187 188
188 EXPECT_CALL(mock_tab_observer, OnFirstPendingLoad(_)); 189 EXPECT_CALL(mock_tab_observer, OnFirstPendingLoad(_));
189 { 190 {
190 testing::InSequence expect_in_sequence; 191 testing::InSequence expect_in_sequence;
191 EXPECT_CALL(mock_notification_observer, Observe( 192 EXPECT_CALL(mock_notification_observer, Observe(
192 testing::Eq(NotificationType::DOM_OPERATION_RESPONSE), _, _)); 193 testing::Eq(chrome::NOTIFICATION_DOM_OPERATION_RESPONSE), _, _));
193 EXPECT_CALL(mock_tab_observer, OnNoMorePendingLoads(_)); 194 EXPECT_CALL(mock_tab_observer, OnNoMorePendingLoads(_));
194 } 195 }
195 196
196 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL( 197 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(
197 test_data_dir_.AppendASCII("sends_message_on_load.html"))); 198 test_data_dir_.AppendASCII("sends_message_on_load.html")));
198 } 199 }
199 200
200 // Tests that a crashed tab reports that it has stopped loading. 201 // Tests that a crashed tab reports that it has stopped loading.
201 IN_PROC_BROWSER_TEST_F(AutomationTabHelperBrowserTest, 202 IN_PROC_BROWSER_TEST_F(AutomationTabHelperBrowserTest,
202 CrashedTabStopsLoading) { 203 CrashedTabStopsLoading) {
203 MockTabEventObserver mock_tab_observer(tab_helper()); 204 MockTabEventObserver mock_tab_observer(tab_helper());
204 205
205 testing::InSequence expect_in_sequence; 206 testing::InSequence expect_in_sequence;
206 EXPECT_CALL(mock_tab_observer, OnFirstPendingLoad(_)); 207 EXPECT_CALL(mock_tab_observer, OnFirstPendingLoad(_));
207 EXPECT_CALL(mock_tab_observer, OnNoMorePendingLoads(_)); 208 EXPECT_CALL(mock_tab_observer, OnNoMorePendingLoads(_));
208 209
209 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); 210 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL));
210 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_resource_tracker.h ('k') | chrome/browser/automation/automation_tab_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698