| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 //#include "chrome/common/url_constants.h" | |
| 15 #include "content/public/browser/resource_request_info.h" | 14 #include "content/public/browser/resource_request_info.h" |
| 16 #include "content/public/test/mock_resource_context.h" | 15 #include "content/public/test/mock_resource_context.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "extensions/browser/extension_protocols.h" | 17 #include "extensions/browser/extension_protocols.h" |
| 19 #include "extensions/browser/info_map.h" | 18 #include "extensions/browser/info_map.h" |
| 20 #include "extensions/common/constants.h" | 19 #include "extensions/common/constants.h" |
| 21 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 22 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
| 23 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
| 24 #include "net/url_request/url_request_job_factory_impl.h" | 23 #include "net/url_request/url_request_job_factory_impl.h" |
| 25 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
| 26 #include "net/url_request/url_request_test_util.h" | 25 #include "net/url_request/url_request_test_util.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 27 |
| 29 using content::ResourceType; | 28 using content::ResourceType; |
| 30 | 29 |
| 31 namespace extensions { | 30 namespace extensions { |
| 31 namespace { |
| 32 | 32 |
| 33 scoped_refptr<Extension> CreateTestExtension(const std::string& name, | 33 scoped_refptr<Extension> CreateTestExtension(const std::string& name, |
| 34 bool incognito_split_mode) { | 34 bool incognito_split_mode) { |
| 35 base::DictionaryValue manifest; | 35 base::DictionaryValue manifest; |
| 36 manifest.SetString("name", name); | 36 manifest.SetString("name", name); |
| 37 manifest.SetString("version", "1"); | 37 manifest.SetString("version", "1"); |
| 38 manifest.SetInteger("manifest_version", 2); | 38 manifest.SetInteger("manifest_version", 2); |
| 39 manifest.SetString("incognito", incognito_split_mode ? "split" : "spanning"); | 39 manifest.SetString("incognito", incognito_split_mode ? "split" : "spanning"); |
| 40 | 40 |
| 41 base::FilePath path; | 41 base::FilePath path; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 path = path.AppendASCII("extensions").AppendASCII("response_headers"); | 82 path = path.AppendASCII("extensions").AppendASCII("response_headers"); |
| 83 | 83 |
| 84 std::string error; | 84 std::string error; |
| 85 scoped_refptr<Extension> extension( | 85 scoped_refptr<Extension> extension( |
| 86 Extension::Create(path, Manifest::UNPACKED, manifest, | 86 Extension::Create(path, Manifest::UNPACKED, manifest, |
| 87 Extension::NO_FLAGS, &error)); | 87 Extension::NO_FLAGS, &error)); |
| 88 EXPECT_TRUE(extension.get()) << error; | 88 EXPECT_TRUE(extension.get()) << error; |
| 89 return extension; | 89 return extension; |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace |
| 93 |
| 94 // This test lives in src/chrome instead of src/extensions because it tests |
| 95 // functionality delegated back to Chrome via ChromeExtensionsBrowserClient. |
| 96 // See chrome/browser/extensions/url_request_util.cc. |
| 92 class ExtensionProtocolTest : public testing::Test { | 97 class ExtensionProtocolTest : public testing::Test { |
| 93 public: | 98 public: |
| 94 ExtensionProtocolTest() | 99 ExtensionProtocolTest() |
| 95 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 100 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 96 old_factory_(NULL), | 101 old_factory_(NULL), |
| 97 resource_context_(&test_url_request_context_) {} | 102 resource_context_(&test_url_request_context_) {} |
| 98 | 103 |
| 99 virtual void SetUp() OVERRIDE { | 104 virtual void SetUp() OVERRIDE { |
| 100 testing::Test::SetUp(); | 105 testing::Test::SetUp(); |
| 101 extension_info_map_ = new InfoMap(); | 106 extension_info_map_ = new InfoMap(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 extension->GetResourceURL("test.dat"), | 355 extension->GetResourceURL("test.dat"), |
| 351 net::DEFAULT_PRIORITY, | 356 net::DEFAULT_PRIORITY, |
| 352 &test_delegate_, | 357 &test_delegate_, |
| 353 NULL)); | 358 NULL)); |
| 354 StartRequest(request.get(), content::RESOURCE_TYPE_MEDIA); | 359 StartRequest(request.get(), content::RESOURCE_TYPE_MEDIA); |
| 355 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); | 360 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); |
| 356 } | 361 } |
| 357 } | 362 } |
| 358 | 363 |
| 359 } // namespace extensions | 364 } // namespace extensions |
| OLD | NEW |