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

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

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile Created 8 years, 8 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/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" 7 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
7 #include "chrome/browser/intents/web_intents_registry.h" 8 #include "chrome/browser/intents/web_intents_registry.h"
8 #include "chrome/browser/intents/web_intents_registry_factory.h" 9 #include "chrome/browser/intents/web_intents_registry_factory.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "content/test/test_browser_thread.h" 13 #include "content/test/test_browser_thread.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 16 matching lines...) Expand all
31 MockWebIntentsRegistry* BuildForProfile(Profile* profile) { 32 MockWebIntentsRegistry* BuildForProfile(Profile* profile) {
32 return static_cast<MockWebIntentsRegistry*>( 33 return static_cast<MockWebIntentsRegistry*>(
33 WebIntentsRegistryFactory::GetInstance()->SetTestingFactoryAndUse( 34 WebIntentsRegistryFactory::GetInstance()->SetTestingFactoryAndUse(
34 profile, BuildMockWebIntentsRegistry)); 35 profile, BuildMockWebIntentsRegistry));
35 } 36 }
36 37
37 class RegisterIntentHandlerInfoBarDelegateTest 38 class RegisterIntentHandlerInfoBarDelegateTest
38 : public TabContentsWrapperTestHarness { 39 : public TabContentsWrapperTestHarness {
39 protected: 40 protected:
40 RegisterIntentHandlerInfoBarDelegateTest() 41 RegisterIntentHandlerInfoBarDelegateTest()
41 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) {} 42 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()),
43 db_thread_(BrowserThread::DB) {}
42 44
43 virtual void SetUp() { 45 virtual void SetUp() {
46 db_thread_.Start();
44 TabContentsWrapperTestHarness::SetUp(); 47 TabContentsWrapperTestHarness::SetUp();
45 48
46 profile()->CreateWebDataService(false);
47 web_intents_registry_ = BuildForProfile(profile()); 49 web_intents_registry_ = BuildForProfile(profile());
48 } 50 }
49 51
50 virtual void TearDown() { 52 virtual void TearDown() {
51 web_intents_registry_ = NULL; 53 web_intents_registry_ = NULL;
52 54
53 TabContentsWrapperTestHarness::TearDown(); 55 TabContentsWrapperTestHarness::TearDown();
56 // Schedule another task on the DB thread to notify us that it's safe to
57 // carry on with the test.
58 base::WaitableEvent done(false, false);
59 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
60 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
61 done.Wait();
62 db_thread_.Stop();
54 } 63 }
55 64
56 MockWebIntentsRegistry* web_intents_registry_; 65 MockWebIntentsRegistry* web_intents_registry_;
57 66
58 private: 67 private:
59 content::TestBrowserThread ui_thread_; 68 content::TestBrowserThread ui_thread_;
69 content::TestBrowserThread db_thread_;
60 70
61 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest); 71 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest);
62 }; 72 };
63 73
64 TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) { 74 TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) {
65 webkit_glue::WebIntentServiceData service; 75 webkit_glue::WebIntentServiceData service;
66 service.service_url = GURL("google.com"); 76 service.service_url = GURL("google.com");
67 service.action = ASCIIToUTF16("http://webintents.org/share"); 77 service.action = ASCIIToUTF16("http://webintents.org/share");
68 service.type = ASCIIToUTF16("text/url"); 78 service.type = ASCIIToUTF16("text/url");
69 RegisterIntentHandlerInfoBarDelegate delegate( 79 RegisterIntentHandlerInfoBarDelegate delegate(
70 contents_wrapper()->infobar_tab_helper(), 80 contents_wrapper()->infobar_tab_helper(),
71 WebIntentsRegistryFactory::GetForProfile(profile()), 81 WebIntentsRegistryFactory::GetForProfile(profile()),
72 service, NULL, GURL()); 82 service, NULL, GURL());
73 83
74 EXPECT_CALL(*web_intents_registry_, RegisterIntentService(service)); 84 EXPECT_CALL(*web_intents_registry_, RegisterIntentService(service));
75 delegate.Accept(); 85 delegate.Accept();
76 } 86 }
77 87
78 } // namespace 88 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/importer/profile_writer.cc ('k') | chrome/browser/intents/web_intents_registry_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698