| 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/strings/string_number_conversions.h" | 5 #include "base/strings/string_number_conversions.h" |
| 6 #include "chrome/common/extensions/extension_builder.h" | 6 #include "chrome/common/extensions/extension_builder.h" |
| 7 #include "chrome/common/extensions/extension_manifest_constants.h" | 7 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 8 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 8 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 9 #include "chrome/common/extensions/manifest_url_handler.h" | 9 #include "chrome/common/extensions/manifest_url_handler.h" |
| 10 #include "chrome/common/extensions/mime_types_handler.h" | 10 #include "chrome/common/extensions/mime_types_handler.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 .SetID(extension_misc::kQuickOfficeExtensionId) | 30 .SetID(extension_misc::kQuickOfficeExtensionId) |
| 31 .SetManifest(DictionaryBuilder() | 31 .SetManifest(DictionaryBuilder() |
| 32 .Set("name", "MIME type handler test") | 32 .Set("name", "MIME type handler test") |
| 33 .Set("version", "1.0.0") | 33 .Set("version", "1.0.0") |
| 34 .Set("manifest_version", 2) | 34 .Set("manifest_version", 2) |
| 35 .Set("mime_types", ListBuilder() | 35 .Set("mime_types", ListBuilder() |
| 36 .Append("plain/text"))) | 36 .Append("plain/text"))) |
| 37 .Build(); | 37 .Build(); |
| 38 | 38 |
| 39 ASSERT_TRUE(extension.get()); | 39 ASSERT_TRUE(extension.get()); |
| 40 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 40 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension.get()); |
| 41 ASSERT_TRUE(handler != NULL); | 41 ASSERT_TRUE(handler != NULL); |
| 42 | 42 |
| 43 EXPECT_FALSE(handler->CanHandleMIMEType("plain/html")); | 43 EXPECT_FALSE(handler->CanHandleMIMEType("plain/html")); |
| 44 EXPECT_TRUE(handler->CanHandleMIMEType("plain/text")); | 44 EXPECT_TRUE(handler->CanHandleMIMEType("plain/text")); |
| 45 } | 45 } |
| 46 | 46 |
| 47 TEST_F(StreamsPrivateManifestTest, | 47 TEST_F(StreamsPrivateManifestTest, |
| 48 MimeTypesHandlerMIMETypesNotWhitelisted) { | 48 MimeTypesHandlerMIMETypesNotWhitelisted) { |
| 49 scoped_refptr<const Extension> extension = | 49 scoped_refptr<const Extension> extension = |
| 50 ExtensionBuilder() | 50 ExtensionBuilder() |
| 51 .SetManifest(DictionaryBuilder() | 51 .SetManifest(DictionaryBuilder() |
| 52 .Set("name", "MIME types test") | 52 .Set("name", "MIME types test") |
| 53 .Set("version", "1.0.0") | 53 .Set("version", "1.0.0") |
| 54 .Set("manifest_version", 2) | 54 .Set("manifest_version", 2) |
| 55 .Set("mime_types", ListBuilder() | 55 .Set("mime_types", ListBuilder() |
| 56 .Append("plain/text"))) | 56 .Append("plain/text"))) |
| 57 .Build(); | 57 .Build(); |
| 58 | 58 |
| 59 ASSERT_TRUE(extension.get()); | 59 ASSERT_TRUE(extension.get()); |
| 60 | 60 |
| 61 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 61 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension.get()); |
| 62 ASSERT_TRUE(handler == NULL); | 62 ASSERT_TRUE(handler == NULL); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| OLD | NEW |