| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/profiles/profile.h" | |
| 6 #include "chrome/browser/ui/browser.h" | |
| 7 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" | |
| 8 #include "chrome/browser/ui/intents/web_intent_picker.h" | |
| 9 #include "chrome/test/base/browser_with_test_window_test.h" | |
| 10 #include "chrome/test/base/testing_profile.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
| 12 #include "content/public/common/url_constants.h" | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | |
| 14 | |
| 15 class WebIntentPickerMock : public WebIntentPicker { | |
| 16 public: | |
| 17 virtual void Close() OVERRIDE {} | |
| 18 virtual void SetActionString(const string16& action) OVERRIDE {} | |
| 19 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE {} | |
| 20 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE {} | |
| 21 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE {} | |
| 22 virtual void OnPendingAsyncCompleted() OVERRIDE {} | |
| 23 virtual void InvalidateDelegate() OVERRIDE {} | |
| 24 }; | |
| 25 | |
| 26 class WebIntentInlineDispositionBrowserTest | |
| 27 : public BrowserWithTestWindowTest { | |
| 28 public: | |
| 29 virtual void SetUp() { | |
| 30 BrowserWithTestWindowTest::SetUp(); | |
| 31 | |
| 32 web_contents_.reset(content::WebContents::Create( | |
| 33 content::WebContents::CreateParams(browser()->profile()))); | |
| 34 delegate_.reset(new WebIntentInlineDispositionDelegate( | |
| 35 &mock_, web_contents_.get(), browser())); | |
| 36 } | |
| 37 | |
| 38 protected: | |
| 39 TestingProfile profile_; | |
| 40 scoped_ptr<content::WebContents> web_contents_; | |
| 41 scoped_ptr<WebIntentInlineDispositionDelegate> delegate_; | |
| 42 WebIntentPickerMock mock_; | |
| 43 }; | |
| 44 | |
| 45 // Verifies delegate's OpenURLFromTab works. This allows navigation inside | |
| 46 // web intents picker. | |
| 47 TEST_F(WebIntentInlineDispositionBrowserTest, OpenURLFromTabTest) { | |
| 48 content::WebContents* source = delegate_->OpenURLFromTab( | |
| 49 web_contents_.get(), | |
| 50 content::OpenURLParams(GURL(chrome::kAboutBlankURL), | |
| 51 content::Referrer(), | |
| 52 NEW_FOREGROUND_TAB, | |
| 53 content::PAGE_TRANSITION_LINK, | |
| 54 false)); | |
| 55 | |
| 56 // Ensure OpenURLFromTab loaded about::blank in |web_contents_|. | |
| 57 ASSERT_EQ(web_contents_.get(), source); | |
| 58 EXPECT_EQ(GURL(chrome::kAboutBlankURL).spec(), source->GetURL().spec()); | |
| 59 } | |
| OLD | NEW |