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

Side by Side 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: Cleanups and fixes. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "base/scoped_ptr.h"
6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
8 #include "chrome/browser/intents/web_intents_registry.h"
9 #include "chrome/browser/intents/web_intent_data.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "content/browser/browser_thread.h"
12 #include "content/browser/renderer_host/test_render_view_host.h"
13 #include "content/browser/site_instance.h"
14 #include "content/browser/tab_contents/test_tab_contents.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace {
19
20 class MockWebIntentsRegistry : public WebIntentsRegistry {
21 public:
22 MOCK_METHOD1(RegisterIntentProvider, void(const WebIntentData&));
23 };
24
25 class RegisterIntentHandlerInfoBarDelegateTest
26 : public RenderViewHostTestHarness {
27 protected:
28 RegisterIntentHandlerInfoBarDelegateTest()
29 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) {}
30
31 virtual void SetUp() {
32 RenderViewHostTestHarness::SetUp();
33
34 profile_.reset(new TestingProfile);
35 profile_->CreateWebDataService(false);
36
37 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get());
38 tab_contents_.reset(new TestTabContents(profile_.get(), instance));
39
40 web_intents_registry_ = new MockWebIntentsRegistry;
41 web_intents_registry_->Initialize(
42 profile_->GetWebDataServiceWithoutCreating());
43 profile_->SetWebIntentsRegistry(web_intents_registry_);
44 }
45
46 virtual void TearDown() {
47 tab_contents_.reset();
48 web_intents_registry_ = NULL;
49 profile_.reset();
50
51 RenderViewHostTestHarness::TearDown();
52 }
53
54 scoped_ptr<TestTabContents> tab_contents_;
55 scoped_refptr<MockWebIntentsRegistry> web_intents_registry_;
56
57 private:
58 BrowserThread ui_thread_;
59 scoped_ptr<TestingProfile> profile_;
60
61 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest);
62 };
63
64 TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) {
65 WebIntentData intent;
66 intent.service_url = GURL("google.com");
67 intent.action = ASCIIToUTF16("http://webintents.org/share");
68 intent.type = ASCIIToUTF16("text/url");
69 RegisterIntentHandlerInfoBarDelegate delegate(tab_contents_.get(), intent);
70
71 EXPECT_CALL(*web_intents_registry_, RegisterIntentProvider(intent));
72 delegate.Accept();
73 }
74
75 }
groby-ooo-7-16 2011/08/09 01:58:15 Don't we usually mark end-of-namespace with "// na
James Hawkins 2011/08/09 02:26:52 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698