OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
10 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util.
h" | 10 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util.
h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
| 13 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "net/test/test_server.h" | 21 #include "net/test/test_server.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
22 | 23 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 base::IntToString(ssl_test_server_->host_port_pair().port()) + | 132 base::IntToString(ssl_test_server_->host_port_pair().port()) + |
132 "&redirect=" + (redirect ? "true" : "false") + | 133 "&redirect=" + (redirect ? "true" : "false") + |
133 "&link=" + | 134 "&link=" + |
134 (button == WebKit::WebMouseEvent::ButtonNone ? "false" : "true") + | 135 (button == WebKit::WebMouseEvent::ButtonNone ? "false" : "true") + |
135 "&target=" + (target_blank ? "_blank" : "")); | 136 "&target=" + (target_blank ? "_blank" : "")); |
136 | 137 |
137 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( | 138 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( |
138 content::NotificationService::AllSources()); | 139 content::NotificationService::AllSources()); |
139 | 140 |
140 string16 expected_title = GetExpectedTitle(start_url, expected_referrer); | 141 string16 expected_title = GetExpectedTitle(start_url, expected_referrer); |
141 content::WebContents* tab = browser()->GetActiveWebContents(); | 142 content::WebContents* tab = chrome::GetActiveWebContents(browser()); |
142 ui_test_utils::TitleWatcher title_watcher(tab, expected_title); | 143 ui_test_utils::TitleWatcher title_watcher(tab, expected_title); |
143 | 144 |
144 // Watch for all possible outcomes to avoid timeouts if something breaks. | 145 // Watch for all possible outcomes to avoid timeouts if something breaks. |
145 AddAllPossibleTitles(start_url, &title_watcher); | 146 AddAllPossibleTitles(start_url, &title_watcher); |
146 | 147 |
147 ui_test_utils::NavigateToURL(browser(), start_url); | 148 ui_test_utils::NavigateToURL(browser(), start_url); |
148 | 149 |
149 if (button != WebKit::WebMouseEvent::ButtonNone) { | 150 if (button != WebKit::WebMouseEvent::ButtonNone) { |
150 WebKit::WebMouseEvent mouse_event; | 151 WebKit::WebMouseEvent mouse_event; |
151 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 152 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // Navigate from A to B. | 372 // Navigate from A to B. |
372 GURL start_url = RunReferrerTest("origin", true, false, true, false, | 373 GURL start_url = RunReferrerTest("origin", true, false, true, false, |
373 WebKit::WebMouseEvent::ButtonLeft, | 374 WebKit::WebMouseEvent::ButtonLeft, |
374 EXPECT_ORIGIN_AS_REFERRER); | 375 EXPECT_ORIGIN_AS_REFERRER); |
375 | 376 |
376 // Navigate to C. | 377 // Navigate to C. |
377 ui_test_utils::NavigateToURL(browser(), test_server_->GetURL("")); | 378 ui_test_utils::NavigateToURL(browser(), test_server_->GetURL("")); |
378 | 379 |
379 string16 expected_title = | 380 string16 expected_title = |
380 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); | 381 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); |
381 content::WebContents* tab = browser()->GetActiveWebContents(); | 382 content::WebContents* tab = chrome::GetActiveWebContents(browser()); |
382 scoped_ptr<ui_test_utils::TitleWatcher> title_watcher( | 383 scoped_ptr<ui_test_utils::TitleWatcher> title_watcher( |
383 new ui_test_utils::TitleWatcher(tab, expected_title)); | 384 new ui_test_utils::TitleWatcher(tab, expected_title)); |
384 | 385 |
385 // Watch for all possible outcomes to avoid timeouts if something breaks. | 386 // Watch for all possible outcomes to avoid timeouts if something breaks. |
386 AddAllPossibleTitles(start_url, title_watcher.get()); | 387 AddAllPossibleTitles(start_url, title_watcher.get()); |
387 | 388 |
388 // Go back to B. | 389 // Go back to B. |
389 chrome::GoBack(browser(), CURRENT_TAB); | 390 chrome::GoBack(browser(), CURRENT_TAB); |
390 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 391 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
391 | 392 |
392 title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title)); | 393 title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title)); |
393 AddAllPossibleTitles(start_url, title_watcher.get()); | 394 AddAllPossibleTitles(start_url, title_watcher.get()); |
394 | 395 |
395 // Reload to B. | 396 // Reload to B. |
396 chrome::Reload(browser(), CURRENT_TAB); | 397 chrome::Reload(browser(), CURRENT_TAB); |
397 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 398 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
398 | 399 |
399 title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title)); | 400 title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title)); |
400 AddAllPossibleTitles(start_url, title_watcher.get()); | 401 AddAllPossibleTitles(start_url, title_watcher.get()); |
401 | 402 |
402 // Shift-reload to B. | 403 // Shift-reload to B. |
403 chrome::ReloadIgnoringCache(browser(), CURRENT_TAB); | 404 chrome::ReloadIgnoringCache(browser(), CURRENT_TAB); |
404 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 405 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
405 } | 406 } |
OLD | NEW |