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