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

Side by Side Diff: chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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
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 "base/synchronization/waitable_event.h" 5 #include "base/synchronization/waitable_event.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/api/infobars/infobar_service.h"
8 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" 7 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
9 #include "chrome/browser/intents/web_intents_registry.h" 8 #include "chrome/browser/intents/web_intents_registry.h"
10 #include "chrome/browser/intents/web_intents_registry_factory.h" 9 #include "chrome/browser/intents/web_intents_registry_factory.h"
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
12 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
13 #include "content/public/test/test_browser_thread.h" 12 #include "content/public/test/test_browser_thread.h"
14 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webkit/glue/web_intent_service_data.h" 15 #include "webkit/glue/web_intent_service_data.h"
17 16
(...skipping 19 matching lines...) Expand all
37 36
38 class RegisterIntentHandlerInfoBarDelegateTest 37 class RegisterIntentHandlerInfoBarDelegateTest
39 : public ChromeRenderViewHostTestHarness { 38 : public ChromeRenderViewHostTestHarness {
40 protected: 39 protected:
41 RegisterIntentHandlerInfoBarDelegateTest() 40 RegisterIntentHandlerInfoBarDelegateTest()
42 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()), 41 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()),
43 db_thread_(BrowserThread::DB, MessageLoopForUI::current()) {} 42 db_thread_(BrowserThread::DB, MessageLoopForUI::current()) {}
44 43
45 virtual void SetUp() { 44 virtual void SetUp() {
46 ChromeRenderViewHostTestHarness::SetUp(); 45 ChromeRenderViewHostTestHarness::SetUp();
47 InfoBarService::CreateForWebContents(web_contents());
48 46
49 profile()->CreateWebDataService(); 47 profile()->CreateWebDataService();
50 web_intents_registry_ = BuildForProfile(profile()); 48 web_intents_registry_ = BuildForProfile(profile());
51 } 49 }
52 50
53 virtual void TearDown() { 51 virtual void TearDown() {
54 web_intents_registry_ = NULL; 52 web_intents_registry_ = NULL;
55 53
56 ChromeRenderViewHostTestHarness::TearDown(); 54 ChromeRenderViewHostTestHarness::TearDown();
57 } 55 }
58 56
59 MockWebIntentsRegistry* web_intents_registry_; 57 MockWebIntentsRegistry* web_intents_registry_;
60 58
61 private: 59 private:
62 content::TestBrowserThread ui_thread_; 60 content::TestBrowserThread ui_thread_;
63 content::TestBrowserThread db_thread_; 61 content::TestBrowserThread db_thread_;
64 62
65 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest); 63 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest);
66 }; 64 };
67 65
68 TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) { 66 TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) {
69 webkit_glue::WebIntentServiceData service; 67 webkit_glue::WebIntentServiceData service;
70 service.service_url = GURL("google.com"); 68 service.service_url = GURL("google.com");
71 service.action = ASCIIToUTF16("http://webintents.org/share"); 69 service.action = ASCIIToUTF16("http://webintents.org/share");
72 service.type = ASCIIToUTF16("text/url"); 70 service.type = ASCIIToUTF16("text/url");
73 RegisterIntentHandlerInfoBarDelegate delegate( 71 scoped_ptr<RegisterIntentHandlerInfoBarDelegate> infobar_delegate(
74 InfoBarService::FromWebContents(web_contents()), 72 RegisterIntentHandlerInfoBarDelegate::Create(web_intents_registry_,
75 WebIntentsRegistryFactory::GetForProfile(profile()), 73 service));
76 service, NULL, GURL());
77 74
78 EXPECT_CALL(*web_intents_registry_, RegisterIntentService(service)); 75 EXPECT_CALL(*web_intents_registry_, RegisterIntentService(service));
79 delegate.Accept(); 76 infobar_delegate->Accept();
80 } 77 }
81 78
82 } // namespace 79 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698