Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6295)

Unified Diff: chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc

Issue 7601013: Web Intents: Hook up the register intent InfoBar with the WebIntentsRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes and more\! Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c65420f9722032d1a77422d712bc6a24227d957c
--- /dev/null
+++ b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
+#include "chrome/browser/intents/web_intents_registry.h"
+#include "chrome/browser/intents/web_intent_data.h"
+#include "chrome/test/base/testing_profile.h"
+#include "content/browser/browser_thread.h"
+#include "content/browser/renderer_host/test_render_view_host.h"
+#include "content/browser/site_instance.h"
+#include "content/browser/tab_contents/test_tab_contents.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class MockWebIntentsRegistry : public WebIntentsRegistry {
+ public:
+ MOCK_METHOD1(RegisterIntentProvider, void(const WebIntentData&));
+};
+
+class RegisterIntentHandlerInfoBarDelegateTest
+ : public RenderViewHostTestHarness {
+ protected:
+ RegisterIntentHandlerInfoBarDelegateTest()
+ : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) {}
+
+ virtual void SetUp() {
+ RenderViewHostTestHarness::SetUp();
+
+ profile_.reset(new TestingProfile);
+ profile_->CreateWebDataService(false);
+
+ SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get());
+ tab_contents_.reset(new TestTabContents(profile_.get(), instance));
+
+ web_intents_registry_ = new MockWebIntentsRegistry;
+ web_intents_registry_->Initialize(
+ profile_->GetWebDataServiceWithoutCreating());
+ profile_->SetWebIntentsRegistry(web_intents_registry_);
+ }
+
+ virtual void TearDown() {
+ tab_contents_.reset();
+ web_intents_registry_ = NULL;
groby-ooo-7-16 2011/08/09 18:17:33 Nit: .release() instead? (For consistency's sake)
James Hawkins 2011/08/09 18:39:03 release() doesn't call Release(), whereas setting
+ profile_.reset();
+
+ RenderViewHostTestHarness::TearDown();
+ }
+
+ scoped_ptr<TestTabContents> tab_contents_;
+ scoped_refptr<MockWebIntentsRegistry> web_intents_registry_;
+
+ private:
+ BrowserThread ui_thread_;
+ scoped_ptr<TestingProfile> profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest);
+};
+
+TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) {
+ WebIntentData intent;
+ intent.service_url = GURL("google.com");
+ intent.action = ASCIIToUTF16("http://webintents.org/share");
+ intent.type = ASCIIToUTF16("text/url");
+ RegisterIntentHandlerInfoBarDelegate delegate(tab_contents_.get(), intent);
+
+ EXPECT_CALL(*web_intents_registry_, RegisterIntentProvider(intent));
+ delegate.Accept();
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698