Commit 9b3fdb53 authored by Ewann's avatar Ewann Committed by Commit Bot

[iOS][OpenIn] Adds unit tests

This CL adds parametrized tests in order to be able to test the different file types added with the kExtendOpenInFilesSupport feature.

Bug: 1117398
Change-Id: I1c7fc04cc9ce2c0ac2f9f6a135b50fea524f2267
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379716
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811240}
parent 10565066
......@@ -38,6 +38,7 @@ source_set("unit_tests") {
testonly = true
sources = [ "open_in_tab_helper_unittest.mm" ]
deps = [
":features",
":open_in",
"//base",
"//base/test:test_support",
......
......@@ -14,6 +14,43 @@ namespace net {
class HttpResponseHeaders;
} // namespace net
namespace content_type {
// .pptx extension.
extern const char kMimeTypeMicrosoftPowerPointOpenXML[];
// .docx extension.
extern const char kMimeTypeMicrosoftWordOpenXML[];
// .xlsx extension.
extern const char kMimeTypeMicrosoftExcelOpenXML[];
// .pdf extension.
extern const char kMimeTypePDF[];
// .doc extension.
extern const char kMimeTypeMicrosoftWord[];
// .jpeg or .jpg extension.
extern const char kMimeTypeJPEG[];
// .png extension.
extern const char kMimeTypePNG[];
// .ppt extension.
extern const char kMimeTypeMicrosoftPowerPoint[];
// .rtf extension.
extern const char kMimeTypeRTF[];
// .svg extension.
extern const char kMimeTypeSVG[];
// .xls extension.
extern const char kMimeTypeMicrosoftExcel[];
} // namespace content_type
// Enum used to determine the MIME type of a previewed file. Entries should
// always keep synced with the IOS.OpenIn.MimeType UMA histogram.
enum class OpenInMimeType {
......
......@@ -25,45 +25,34 @@
#error "This file requires ARC support."
#endif
namespace {
namespace content_type {
// .pptx extension.
const char kMimeTypeMicrosoftPowerPointOpenXML[] =
"application/vnd.openxmlformats-officedocument.presentationml.presentation";
// .docx extension.
const char kMimeTypeMicrosoftWordOpenXML[] =
"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
// .xlsx extension.
const char kMimeTypeMicrosoftExcelOpenXML[] =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
// .pdf extension.
const char kMimeTypePDF[] = "application/pdf";
// .doc extension.
const char kMimeTypeMicrosoftWord[] = "application/msword";
// .jpeg or .jpg extension.
const char kMimeTypeJPEG[] = "image/jpeg";
// .png extension.
const char kMimeTypePNG[] = "image/png";
// .ppt extension.
const char kMimeTypeMicrosoftPowerPoint[] = "application/vnd.ms-powerpoint";
// .rtf extension.
const char kMimeTypeRTF[] = "application/rtf";
// .svg extension.
const char kMimeTypeSVG[] = "image/svg+xml";
// .xls extension.
const char kMimeTypeMicrosoftExcel[] = "application/vnd.ms-excel";
} // namespace
} // namespace content_type
// static
void OpenInTabHelper::CreateForWebState(web::WebState* web_state) {
......@@ -89,27 +78,27 @@ OpenInTabHelper::~OpenInTabHelper() {
OpenInMimeType OpenInTabHelper::GetUmaResult(
const std::string& mime_type) const {
if (mime_type == kMimeTypePDF)
if (mime_type == content_type::kMimeTypePDF)
return OpenInMimeType::kMimeTypePDF;
if (mime_type == kMimeTypeMicrosoftWord)
if (mime_type == content_type::kMimeTypeMicrosoftWord)
return OpenInMimeType::kMimeTypeMicrosoftWord;
if (mime_type == kMimeTypeMicrosoftWordOpenXML)
if (mime_type == content_type::kMimeTypeMicrosoftWordOpenXML)
return OpenInMimeType::kMimeTypeMicrosoftWordOpenXML;
if (mime_type == kMimeTypeJPEG)
if (mime_type == content_type::kMimeTypeJPEG)
return OpenInMimeType::kMimeTypeJPEG;
if (mime_type == kMimeTypePNG)
if (mime_type == content_type::kMimeTypePNG)
return OpenInMimeType::kMimeTypePNG;
if (mime_type == kMimeTypeMicrosoftPowerPoint)
if (mime_type == content_type::kMimeTypeMicrosoftPowerPoint)
return OpenInMimeType::kMimeTypeMicrosoftPowerPoint;
if (mime_type == kMimeTypeMicrosoftPowerPointOpenXML)
if (mime_type == content_type::kMimeTypeMicrosoftPowerPointOpenXML)
return OpenInMimeType::kMimeTypeMicrosoftPowerPointOpenXML;
if (mime_type == kMimeTypeRTF)
if (mime_type == content_type::kMimeTypeRTF)
return OpenInMimeType::kMimeTypeRTF;
if (mime_type == kMimeTypeSVG)
if (mime_type == content_type::kMimeTypeSVG)
return OpenInMimeType::kMimeTypeSVG;
if (mime_type == kMimeTypeMicrosoftExcel)
if (mime_type == content_type::kMimeTypeMicrosoftExcel)
return OpenInMimeType::kMimeTypeMicrosoftExcel;
if (mime_type == kMimeTypeMicrosoftExcelOpenXML)
if (mime_type == content_type::kMimeTypeMicrosoftExcelOpenXML)
return OpenInMimeType::kMimeTypeMicrosoftExcelOpenXML;
return OpenInMimeType::kMimeTypeNotHandled;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment