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 "chrome/browser/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" | 7 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" |
8 #include "chrome/browser/ui/intents/web_intent_picker.h" | 8 #include "chrome/browser/ui/intents/web_intent_picker.h" |
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
10 #include "chrome/test/base/browser_with_test_window_test.h" | 10 #include "chrome/test/base/browser_with_test_window_test.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 }; | 25 }; |
26 | 26 |
27 class WebIntentInlineDispositionBrowserTest | 27 class WebIntentInlineDispositionBrowserTest |
28 : public BrowserWithTestWindowTest { | 28 : public BrowserWithTestWindowTest { |
29 public: | 29 public: |
30 virtual void SetUp() { | 30 virtual void SetUp() { |
31 BrowserWithTestWindowTest::SetUp(); | 31 BrowserWithTestWindowTest::SetUp(); |
32 | 32 |
33 content::WebContents* contents = content::WebContents::Create( | 33 content::WebContents* contents = content::WebContents::Create( |
34 browser()->profile(), NULL, MSG_ROUTING_NONE, NULL); | 34 browser()->profile(), NULL, MSG_ROUTING_NONE, NULL); |
35 tab_contents_.reset(new TabContents(contents)); | 35 tab_contents_.reset(TabContents::Factory::CreateTabContents(contents)); |
36 delegate_.reset(new WebIntentInlineDispositionDelegate( | 36 delegate_.reset(new WebIntentInlineDispositionDelegate( |
37 &mock_, contents, browser())); | 37 &mock_, contents, browser())); |
38 } | 38 } |
39 | 39 |
40 protected: | 40 protected: |
41 TestingProfile profile_; | 41 TestingProfile profile_; |
42 scoped_ptr<TabContents> tab_contents_; | 42 scoped_ptr<TabContents> tab_contents_; |
43 scoped_ptr<WebIntentInlineDispositionDelegate> delegate_; | 43 scoped_ptr<WebIntentInlineDispositionDelegate> delegate_; |
44 WebIntentPickerMock mock_; | 44 WebIntentPickerMock mock_; |
45 }; | 45 }; |
46 | 46 |
47 // Verifies delegate's OpenURLFromTab works. This allows navigation inside | 47 // Verifies delegate's OpenURLFromTab works. This allows navigation inside |
48 // web intents picker. | 48 // web intents picker. |
49 TEST_F(WebIntentInlineDispositionBrowserTest, OpenURLFromTabTest) { | 49 TEST_F(WebIntentInlineDispositionBrowserTest, OpenURLFromTabTest) { |
50 content::WebContents* source = delegate_->OpenURLFromTab( | 50 content::WebContents* source = delegate_->OpenURLFromTab( |
51 tab_contents_->web_contents(), | 51 tab_contents_->web_contents(), |
52 content::OpenURLParams(GURL(chrome::kAboutBlankURL), content::Referrer(), | 52 content::OpenURLParams(GURL(chrome::kAboutBlankURL), content::Referrer(), |
53 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); | 53 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); |
54 | 54 |
55 // Ensure OpenURLFromTab loaded about::blank in |web_contents_|. | 55 // Ensure OpenURLFromTab loaded about::blank in |web_contents_|. |
56 ASSERT_EQ(tab_contents_->web_contents(), source); | 56 ASSERT_EQ(tab_contents_->web_contents(), source); |
57 EXPECT_EQ(GURL(chrome::kAboutBlankURL).spec(), source->GetURL().spec()); | 57 EXPECT_EQ(GURL(chrome::kAboutBlankURL).spec(), source->GetURL().spec()); |
58 } | 58 } |
OLD | NEW |