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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/chromeos/extensions/file_browser_handler.h" | 6 #include "chrome/browser/chromeos/extensions/file_browser_handler.h" |
7 #include "chrome/browser/chromeos/extensions/file_browser_resource_throttle.h" | 7 #include "chrome/browser/chromeos/extensions/file_browser_resource_throttle.h" |
8 #include "chrome/browser/extensions/extension_info_map.h" | 8 #include "chrome/browser/extensions/extension_info_map.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/extensions/extension_builder.h" | 10 #include "chrome/common/extensions/extension_builder.h" |
11 #include "chrome/common/extensions/extension_constants.h" | 11 #include "chrome/common/extensions/extension_constants.h" |
12 #include "chrome/common/extensions/extension_manifest_constants.h" | |
13 #include "chrome/common/extensions/manifest_handler.h" | 12 #include "chrome/common/extensions/manifest_handler.h" |
14 #include "chrome/common/extensions/value_builder.h" | 13 #include "chrome/common/extensions/value_builder.h" |
15 #include "content/public/browser/resource_controller.h" | 14 #include "content/public/browser/resource_controller.h" |
16 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 using content::BrowserThread; | 19 using content::BrowserThread; |
21 using extensions::DictionaryBuilder; | 20 using extensions::DictionaryBuilder; |
22 using extensions::Extension; | 21 using extensions::Extension; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 : test_extension_id_("test_extension_id"), | 58 : test_extension_id_("test_extension_id"), |
60 test_render_process_id_(2), | 59 test_render_process_id_(2), |
61 test_render_view_id_(12), | 60 test_render_view_id_(12), |
62 test_request_url_("http://some_url/file.txt"), | 61 test_request_url_("http://some_url/file.txt"), |
63 ui_thread_(content::BrowserThread::UI, &message_loop_), | 62 ui_thread_(content::BrowserThread::UI, &message_loop_), |
64 io_thread_(content::BrowserThread::IO, &message_loop_) { | 63 io_thread_(content::BrowserThread::IO, &message_loop_) { |
65 } | 64 } |
66 | 65 |
67 virtual ~FileBrowserResourceThrottleTest() {} | 66 virtual ~FileBrowserResourceThrottleTest() {} |
68 | 67 |
69 virtual void SetUp() { | 68 virtual void SetUp() OVERRIDE { |
70 extensions::ManifestHandler::Register( | 69 (new FileBrowserHandlerParser)->Register(); |
71 extension_manifest_keys::kFileBrowserHandlers, | |
72 make_linked_ptr(new FileBrowserHandlerParser)); | |
73 // Extension info map must be created before |CreateAndInstallTestExtension| | 70 // Extension info map must be created before |CreateAndInstallTestExtension| |
74 // is called (the method will add created extension to the info map). | 71 // is called (the method will add created extension to the info map). |
75 extension_info_map_ = new ExtensionInfoMap(); | 72 extension_info_map_ = new ExtensionInfoMap(); |
76 CreateAndInstallTestExtension(); | 73 CreateAndInstallTestExtension(); |
77 InitResourceController(); | 74 InitResourceController(); |
78 } | 75 } |
79 | 76 |
80 virtual void TearDown() { | 77 virtual void TearDown() OVERRIDE { |
81 FileBrowserHandler::set_extension_whitelisted_for_test(NULL); | 78 FileBrowserHandler::set_extension_whitelisted_for_test(NULL); |
| 79 extensions::ManifestHandler::ClearRegistryForTesting(); |
82 } | 80 } |
83 | 81 |
84 protected: | 82 protected: |
85 // Creates the test extension, and adds it to the |extension_info_map_|. | 83 // Creates the test extension, and adds it to the |extension_info_map_|. |
86 // The extension has separate file browser handlers that can handle | 84 // The extension has separate file browser handlers that can handle |
87 // 'plain/html' and 'plain/text' MIME types. | 85 // 'plain/html' and 'plain/text' MIME types. |
88 void CreateAndInstallTestExtension() { | 86 void CreateAndInstallTestExtension() { |
89 // The extension must be white-listed in order to be successfully created. | 87 // The extension must be white-listed in order to be successfully created. |
90 FileBrowserHandler::set_extension_whitelisted_for_test( | 88 FileBrowserHandler::set_extension_whitelisted_for_test( |
91 &test_extension_id_); | 89 &test_extension_id_); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 321 |
324 scoped_ptr<FileBrowserResourceThrottle> throttle( | 322 scoped_ptr<FileBrowserResourceThrottle> throttle( |
325 CreateThrottleToTest(true, mock_event_router.Pass(), "plain/html")); | 323 CreateThrottleToTest(true, mock_event_router.Pass(), "plain/html")); |
326 | 324 |
327 bool defer = false; | 325 bool defer = false; |
328 throttle->WillProcessResponse(&defer); | 326 throttle->WillProcessResponse(&defer); |
329 EXPECT_FALSE(defer); | 327 EXPECT_FALSE(defer); |
330 } | 328 } |
331 | 329 |
332 } // namespace | 330 } // namespace |
OLD | NEW |