Chromium Code Reviews| Index: chrome/browser/intents/web_intents_registry_unittest.cc |
| diff --git a/chrome/browser/intents/web_intents_registry_unittest.cc b/chrome/browser/intents/web_intents_registry_unittest.cc |
| index ef1a1e1008edf08118ef52cafcbda5a357283b10..55cff8ba424c3bd6cf42d0e831de4a45992c9f8e 100644 |
| --- a/chrome/browser/intents/web_intents_registry_unittest.cc |
| +++ b/chrome/browser/intents/web_intents_registry_unittest.cc |
| @@ -25,6 +25,8 @@ class MockExtensionService: public TestExtensionService { |
| public: |
| virtual ~MockExtensionService() {} |
| MOCK_CONST_METHOD0(extensions, const ExtensionSet*()); |
| + MOCK_CONST_METHOD2(GetExtensionById, |
| + const Extension*(const std::string&, bool)); |
| }; |
| namespace { |
| @@ -93,6 +95,9 @@ class WebIntentsRegistryTest : public testing::Test { |
| registry_.Initialize(wds_, &extension_service_); |
| EXPECT_CALL(extension_service_, extensions()). |
| WillRepeatedly(testing::Return(&extensions_)); |
| + EXPECT_CALL(extension_service_, GetExtensionById(testing::_, testing::_)). |
| + WillRepeatedly( |
| + testing::Invoke(this, &WebIntentsRegistryTest::GetExtensionById)); |
| } |
| virtual void TearDown() { |
| @@ -104,6 +109,18 @@ class WebIntentsRegistryTest : public testing::Test { |
| MessageLoop::current()->Run(); |
| } |
| + const Extension* GetExtensionById(const std::string& extension_id, |
| + testing::Unused) { |
| + for (ExtensionSet::const_iterator iter = extensions_.begin(); |
| + iter != extensions_.end(); |
|
James Hawkins
2012/03/15 01:05:20
Save a row by putting ++iter up here.
binji
2012/03/15 17:53:14
Done.
|
| + ++iter) { |
| + if ((*iter)->id() == extension_id) |
| + return &**iter; |
| + } |
| + |
| + return NULL; |
| + } |
| + |
| MessageLoopForUI message_loop_; |
| content::TestBrowserThread ui_thread_; |
| content::TestBrowserThread db_thread_; |
| @@ -194,6 +211,21 @@ TEST_F(WebIntentsRegistryTest, BasicTests) { |
| EXPECT_EQ(1U, consumer.services_.size()); |
| } |
| +TEST_F(WebIntentsRegistryTest, GetIntentServicesWithExtensionId) { |
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid.json")); |
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json")); |
| + ASSERT_EQ(2U, extensions_.size()); |
| + |
| + TestConsumer consumer; |
| + consumer.expected_id_ = registry_.GetIntentServicesWithExtensionId( |
| + ASCIIToUTF16("http://webintents.org/edit"), |
| + ASCIIToUTF16("image/*"), |
| + (*extensions_.begin())->id(), |
| + &consumer); |
| + consumer.WaitForData(); |
| + ASSERT_EQ(1U, consumer.services_.size()); |
| +} |
| + |
| TEST_F(WebIntentsRegistryTest, GetAllIntents) { |
| webkit_glue::WebIntentServiceData service; |
| service.service_url = GURL("http://google.com"); |