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 // Navigates the browser to server and client redirect pages and makes sure | 5 // Navigates the browser to server and client redirect pages and makes sure |
6 // that the correct redirects are reflected in the history database. Errors | 6 // that the correct redirects are reflected in the history database. Errors |
7 // here might indicate that WebKit changed the calls our glue layer gets in | 7 // here might indicate that WebKit changed the calls our glue layer gets in |
8 // the case of redirects. It may also mean problems with the history system. | 8 // the case of redirects. It may also mean problems with the history system. |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/location.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/single_thread_task_runner.h" |
14 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
18 #include "base/task/cancelable_task_tracker.h" | 20 #include "base/task/cancelable_task_tracker.h" |
19 #include "base/test/test_timeouts.h" | 21 #include "base/test/test_timeouts.h" |
| 22 #include "base/thread_task_runner_handle.h" |
20 #include "base/threading/platform_thread.h" | 23 #include "base/threading/platform_thread.h" |
21 #include "chrome/browser/history/history_service_factory.h" | 24 #include "chrome/browser/history/history_service_factory.h" |
22 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
25 #include "chrome/browser/ui/view_ids.h" | 28 #include "chrome/browser/ui/view_ids.h" |
26 #include "chrome/test/base/in_process_browser_test.h" | 29 #include "chrome/test/base/in_process_browser_test.h" |
27 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
28 #include "components/history/core/browser/history_service.h" | 31 #include "components/history/core/browser/history_service.h" |
29 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
(...skipping 23 matching lines...) Expand all Loading... |
53 &rv), | 56 &rv), |
54 &tracker_); | 57 &tracker_); |
55 content::RunMessageLoop(); | 58 content::RunMessageLoop(); |
56 return rv; | 59 return rv; |
57 } | 60 } |
58 | 61 |
59 protected: | 62 protected: |
60 void OnRedirectQueryComplete(std::vector<GURL>* rv, | 63 void OnRedirectQueryComplete(std::vector<GURL>* rv, |
61 const history::RedirectList* redirects) { | 64 const history::RedirectList* redirects) { |
62 rv->insert(rv->end(), redirects->begin(), redirects->end()); | 65 rv->insert(rv->end(), redirects->begin(), redirects->end()); |
63 base::MessageLoop::current()->PostTask(FROM_HERE, | 66 base::ThreadTaskRunnerHandle::Get()->PostTask( |
64 base::MessageLoop::QuitClosure()); | 67 FROM_HERE, base::MessageLoop::QuitClosure()); |
65 } | 68 } |
66 | 69 |
67 // Tracker for asynchronous history queries. | 70 // Tracker for asynchronous history queries. |
68 base::CancelableTaskTracker tracker_; | 71 base::CancelableTaskTracker tracker_; |
69 }; | 72 }; |
70 | 73 |
71 // Tests a single server redirect | 74 // Tests a single server redirect |
72 IN_PROC_BROWSER_TEST_F(RedirectTest, Server) { | 75 IN_PROC_BROWSER_TEST_F(RedirectTest, Server) { |
73 ASSERT_TRUE(test_server()->Start()); | 76 ASSERT_TRUE(test_server()->Start()); |
74 GURL final_url = test_server()->GetURL(std::string()); | 77 GURL final_url = test_server()->GetURL(std::string()); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // as a client redirect from the first (/client-redirect?) page. | 301 // as a client redirect from the first (/client-redirect?) page. |
299 for (std::vector<GURL>::iterator it = redirects.begin(); | 302 for (std::vector<GURL>::iterator it = redirects.begin(); |
300 it != redirects.end(); ++it) { | 303 it != redirects.end(); ++it) { |
301 if (final_url.spec() == it->spec()) { | 304 if (final_url.spec() == it->spec()) { |
302 final_navigation_not_redirect = false; | 305 final_navigation_not_redirect = false; |
303 break; | 306 break; |
304 } | 307 } |
305 } | 308 } |
306 EXPECT_TRUE(final_navigation_not_redirect); | 309 EXPECT_TRUE(final_navigation_not_redirect); |
307 } | 310 } |
OLD | NEW |