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/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
9 #include "chrome/test/base/browser_with_test_window_test.h" | 10 #include "chrome/test/base/browser_with_test_window_test.h" |
10 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
12 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
| 16 class WebIntentPickerMock : public WebIntentPicker { |
| 17 public: |
| 18 virtual void Close() OVERRIDE {} |
| 19 virtual void SetActionString(const string16& action) OVERRIDE {} |
| 20 }; |
| 21 |
15 class WebIntentInlineDispositionBrowserTest | 22 class WebIntentInlineDispositionBrowserTest |
16 : public BrowserWithTestWindowTest { | 23 : public BrowserWithTestWindowTest { |
17 public: | 24 public: |
18 virtual void SetUp() { | 25 virtual void SetUp() { |
19 BrowserWithTestWindowTest::SetUp(); | 26 BrowserWithTestWindowTest::SetUp(); |
20 | 27 |
21 content::WebContents* contents = content::WebContents::Create( | 28 content::WebContents* contents = content::WebContents::Create( |
22 browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 29 browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
23 wrapper_.reset(new TabContentsWrapper(contents)); | 30 wrapper_.reset(new TabContentsWrapper(contents)); |
24 delegate_.reset(new WebIntentInlineDispositionDelegate); | 31 delegate_.reset(new WebIntentInlineDispositionDelegate(&mock_)); |
25 contents->SetDelegate(delegate_.get()); | 32 contents->SetDelegate(delegate_.get()); |
26 } | 33 } |
27 | 34 |
28 protected: | 35 protected: |
29 TestingProfile profile_; | 36 TestingProfile profile_; |
30 scoped_ptr<TabContentsWrapper> wrapper_; | 37 scoped_ptr<TabContentsWrapper> wrapper_; |
31 scoped_ptr<WebIntentInlineDispositionDelegate> delegate_; | 38 scoped_ptr<WebIntentInlineDispositionDelegate> delegate_; |
| 39 WebIntentPickerMock mock_; |
32 }; | 40 }; |
33 | 41 |
34 // Verifies delegate's OpenURLFromTab works. This allows navigation inside | 42 // Verifies delegate's OpenURLFromTab works. This allows navigation inside |
35 // web intents picker. | 43 // web intents picker. |
36 TEST_F(WebIntentInlineDispositionBrowserTest, OpenURLFromTabTest) { | 44 TEST_F(WebIntentInlineDispositionBrowserTest, OpenURLFromTabTest) { |
37 content::WebContents* source = delegate_->OpenURLFromTab( | 45 content::WebContents* source = delegate_->OpenURLFromTab( |
38 wrapper_->web_contents(), | 46 wrapper_->web_contents(), |
39 content::OpenURLParams(GURL(chrome::kAboutBlankURL), content::Referrer(), | 47 content::OpenURLParams(GURL(chrome::kAboutBlankURL), content::Referrer(), |
40 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); | 48 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); |
41 | 49 |
42 // Ensure OpenURLFromTab loaded about::blank in |web_contents_|. | 50 // Ensure OpenURLFromTab loaded about::blank in |web_contents_|. |
43 ASSERT_EQ(wrapper_->web_contents(), source); | 51 ASSERT_EQ(wrapper_->web_contents(), source); |
44 EXPECT_EQ(GURL(chrome::kAboutBlankURL).spec(), source->GetURL().spec()); | 52 EXPECT_EQ(GURL(chrome::kAboutBlankURL).spec(), source->GetURL().spec()); |
45 } | 53 } |
OLD | NEW |