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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_tabstrip.h" |
8 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
11 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
12 #include "content/public/common/frame_navigate_params.h" | 13 #include "content/public/common/frame_navigate_params.h" |
13 #include "net/test/test_server.h" | 14 #include "net/test/test_server.h" |
14 | 15 |
15 class MultipartResponseTest : public InProcessBrowserTest, | 16 class MultipartResponseTest : public InProcessBrowserTest, |
16 public content::WebContentsObserver { | 17 public content::WebContentsObserver { |
17 public: | 18 public: |
18 MultipartResponseTest() : did_navigate_any_frame_count_(0), | 19 MultipartResponseTest() : did_navigate_any_frame_count_(0), |
19 update_history_count_(0) {} | 20 update_history_count_(0) {} |
20 | 21 |
21 void DidNavigateAnyFrame(const content::LoadCommittedDetails& details, | 22 void DidNavigateAnyFrame(const content::LoadCommittedDetails& details, |
22 const content::FrameNavigateParams& params) { | 23 const content::FrameNavigateParams& params) { |
23 did_navigate_any_frame_count_++; | 24 did_navigate_any_frame_count_++; |
24 if (params.should_update_history) | 25 if (params.should_update_history) |
25 update_history_count_++; | 26 update_history_count_++; |
26 } | 27 } |
27 | 28 |
28 int did_navigate_any_frame_count_; | 29 int did_navigate_any_frame_count_; |
29 int update_history_count_; | 30 int update_history_count_; |
30 }; | 31 }; |
31 | 32 |
32 IN_PROC_BROWSER_TEST_F(MultipartResponseTest, SingleVisit) { | 33 IN_PROC_BROWSER_TEST_F(MultipartResponseTest, SingleVisit) { |
33 // Make sure that visiting a multipart/x-mixed-replace site only | 34 // Make sure that visiting a multipart/x-mixed-replace site only |
34 // creates one entry in the visits table. | 35 // creates one entry in the visits table. |
35 ASSERT_TRUE(test_server()->Start()); | 36 ASSERT_TRUE(test_server()->Start()); |
36 | 37 |
37 Observe(browser()->GetActiveWebContents()); | 38 Observe(chrome::GetActiveWebContents(browser())); |
38 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("multipart")); | 39 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("multipart")); |
39 | 40 |
40 EXPECT_EQ(ASCIIToUTF16("page 9"), | 41 EXPECT_EQ(ASCIIToUTF16("page 9"), |
41 browser()->GetActiveWebContents()->GetTitle()); | 42 chrome::GetActiveWebContents(browser())->GetTitle()); |
42 EXPECT_EQ(1, update_history_count_); | 43 EXPECT_EQ(1, update_history_count_); |
43 EXPECT_GT(did_navigate_any_frame_count_, update_history_count_); | 44 EXPECT_GT(did_navigate_any_frame_count_, update_history_count_); |
44 } | 45 } |
OLD | NEW |