OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/json/json_value_serializer.h" | 6 #include "base/json/json_value_serializer.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/intents/web_intents_registry.h" | 10 #include "chrome/browser/intents/web_intents_registry.h" |
11 #include "chrome/browser/webdata/web_data_service.h" | 11 #include "chrome/browser/webdata/web_data_service.h" |
12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.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" |
15 | 16 |
16 class MockExtensionService: public ExtensionServiceInterface { | 17 class MockExtensionService: public ExtensionServiceInterface { |
17 public: | 18 public: |
18 virtual ~MockExtensionService() {} | 19 virtual ~MockExtensionService() {} |
19 MOCK_CONST_METHOD0(extensions, const ExtensionList*()); | 20 MOCK_CONST_METHOD0(extensions, const ExtensionList*()); |
20 MOCK_METHOD0(pending_extension_manager, PendingExtensionManager*()); | 21 MOCK_METHOD0(pending_extension_manager, PendingExtensionManager*()); |
21 MOCK_METHOD4(UpdateExtension, bool(const std::string& id, | 22 MOCK_METHOD4(UpdateExtension, bool(const std::string& id, |
22 const FilePath& path, | 23 const FilePath& path, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 virtual void TearDown() { | 125 virtual void TearDown() { |
125 if (wds_.get()) | 126 if (wds_.get()) |
126 wds_->Shutdown(); | 127 wds_->Shutdown(); |
127 | 128 |
128 db_thread_.Stop(); | 129 db_thread_.Stop(); |
129 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 130 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
130 MessageLoop::current()->Run(); | 131 MessageLoop::current()->Run(); |
131 } | 132 } |
132 | 133 |
133 MessageLoopForUI message_loop_; | 134 MessageLoopForUI message_loop_; |
134 BrowserThread ui_thread_; | 135 content::TestBrowserThread ui_thread_; |
135 BrowserThread db_thread_; | 136 content::TestBrowserThread db_thread_; |
136 scoped_refptr<WebDataService> wds_; | 137 scoped_refptr<WebDataService> wds_; |
137 MockExtensionService extensionService_; | 138 MockExtensionService extensionService_; |
138 ExtensionList extensions_; | 139 ExtensionList extensions_; |
139 WebIntentsRegistry registry_; | 140 WebIntentsRegistry registry_; |
140 ScopedTempDir temp_dir_; | 141 ScopedTempDir temp_dir_; |
141 }; | 142 }; |
142 | 143 |
143 // Simple consumer for WebIntentsRegistry notifications. Stores result data and | 144 // Simple consumer for WebIntentsRegistry notifications. Stores result data and |
144 // terminates UI thread when callback is invoked. | 145 // terminates UI thread when callback is invoked. |
145 class TestConsumer: public WebIntentsRegistry::Consumer { | 146 class TestConsumer: public WebIntentsRegistry::Consumer { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 consumer.expected_id_ = registry_.GetIntentProviders( | 264 consumer.expected_id_ = registry_.GetIntentProviders( |
264 ASCIIToUTF16("http://webintents.org/edit"),&consumer); | 265 ASCIIToUTF16("http://webintents.org/edit"),&consumer); |
265 consumer.WaitForData(); | 266 consumer.WaitForData(); |
266 ASSERT_EQ(2U, consumer.services_.size()); | 267 ASSERT_EQ(2U, consumer.services_.size()); |
267 | 268 |
268 consumer.expected_id_ = registry_.GetIntentProviders( | 269 consumer.expected_id_ = registry_.GetIntentProviders( |
269 ASCIIToUTF16("http://webintents.org/share"),&consumer); | 270 ASCIIToUTF16("http://webintents.org/share"),&consumer); |
270 consumer.WaitForData(); | 271 consumer.WaitForData(); |
271 ASSERT_EQ(1U, consumer.services_.size()); | 272 ASSERT_EQ(1U, consumer.services_.size()); |
272 } | 273 } |
OLD | NEW |