| OLD | NEW |
| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/extensions/test_extension_service.h" | 13 #include "chrome/browser/extensions/test_extension_service.h" |
| 14 #include "chrome/browser/intents/default_web_intent_service.h" | 14 #include "chrome/browser/intents/default_web_intent_service.h" |
| 15 #include "chrome/browser/intents/web_intents_registry.h" | 15 #include "chrome/browser/intents/web_intents_registry.h" |
| 16 #include "chrome/browser/webdata/web_data_service.h" | 16 #include "chrome/browser/webdata/web_data_service.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 18 #include "chrome/common/extensions/extension_set.h" | 19 #include "chrome/common/extensions/extension_set.h" |
| 20 #include "chrome/common/extensions/manifest_handler.h" |
| 21 #include "chrome/common/extensions/web_intents_handler.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 25 |
| 23 using content::BrowserThread; | 26 using content::BrowserThread; |
| 24 using extensions::Extension; | 27 using extensions::Extension; |
| 25 using webkit_glue::WebIntentServiceData; | 28 using webkit_glue::WebIntentServiceData; |
| 26 | 29 |
| 27 class MockExtensionService: public TestExtensionService { | 30 class MockExtensionService: public TestExtensionService { |
| 28 public: | 31 public: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 db_thread_.Start(); | 93 db_thread_.Start(); |
| 91 wds_ = new WebDataService(); | 94 wds_ = new WebDataService(); |
| 92 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 95 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 93 wds_->Init(temp_dir_.path()); | 96 wds_->Init(temp_dir_.path()); |
| 94 registry_.Initialize(wds_, &extension_service_); | 97 registry_.Initialize(wds_, &extension_service_); |
| 95 EXPECT_CALL(extension_service_, extensions()). | 98 EXPECT_CALL(extension_service_, extensions()). |
| 96 WillRepeatedly(testing::Return(&extensions_)); | 99 WillRepeatedly(testing::Return(&extensions_)); |
| 97 EXPECT_CALL(extension_service_, GetExtensionById(testing::_, testing::_)). | 100 EXPECT_CALL(extension_service_, GetExtensionById(testing::_, testing::_)). |
| 98 WillRepeatedly( | 101 WillRepeatedly( |
| 99 testing::Invoke(this, &WebIntentsRegistryTest::GetExtensionById)); | 102 testing::Invoke(this, &WebIntentsRegistryTest::GetExtensionById)); |
| 103 extensions::ManifestHandler::Register(extension_manifest_keys::kIntents, |
| 104 new extensions::WebIntentsHandler); |
| 100 } | 105 } |
| 101 | 106 |
| 102 virtual void TearDown() { | 107 virtual void TearDown() { |
| 103 // Clear all references to wds to force it destruction. | 108 // Clear all references to wds to force it destruction. |
| 104 wds_->ShutdownOnUIThread(); | 109 wds_->ShutdownOnUIThread(); |
| 105 wds_ = NULL; | 110 wds_ = NULL; |
| 106 | 111 |
| 107 // Schedule another task on the DB thread to notify us that it's safe to | 112 // Schedule another task on the DB thread to notify us that it's safe to |
| 108 // carry on with the test. | 113 // carry on with the test. |
| 109 base::WaitableEvent done(false, false); | 114 base::WaitableEvent done(false, false); |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 | 794 |
| 790 registry_.GetAllDefaultIntentServices( | 795 registry_.GetAllDefaultIntentServices( |
| 791 base::Bind(&DefaultServiceListConsumer::Accept, | 796 base::Bind(&DefaultServiceListConsumer::Accept, |
| 792 base::Unretained(&consumer))); | 797 base::Unretained(&consumer))); |
| 793 | 798 |
| 794 consumer.WaitForData(); | 799 consumer.WaitForData(); |
| 795 | 800 |
| 796 ASSERT_EQ(1U, consumer.services_.size()); | 801 ASSERT_EQ(1U, consumer.services_.size()); |
| 797 EXPECT_EQ(service_url_1.spec(), consumer.services_[0].service_url); | 802 EXPECT_EQ(service_url_1.spec(), consumer.services_[0].service_url); |
| 798 } | 803 } |
| OLD | NEW |