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