[M108 Migration][HBBTV] Implement ewk_context_register_jsplugin_mime_types API
[platform/framework/web/chromium-efl.git] / pdf / file_extension_unittest.cc
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "pdf/file_extension.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace chrome_pdf {
10
11 TEST(FileExtensionTest, FileNameToExtensionIndex) {
12   // File name with the first known file extension.
13   EXPECT_EQ(ExtensionIndex::k3ga, FileNameToExtensionIndex(u"first.3ga"));
14
15   // File name with the last known file extension.
16   EXPECT_EQ(ExtensionIndex::kTini, FileNameToExtensionIndex(u"last.tini"));
17
18   // File name without an extension.
19   EXPECT_EQ(ExtensionIndex::kEmptyExt,
20             FileNameToExtensionIndex(u"file_no_ext"));
21
22   // File name with an unrecognized file extension.
23   EXPECT_EQ(ExtensionIndex::kOtherExt, FileNameToExtensionIndex(u"file.xyz"));
24
25   // File name with non-ASCII characters.
26   EXPECT_EQ(ExtensionIndex::kPdf, FileNameToExtensionIndex(u"你好.pdf"));
27
28   // Empty file name.
29   EXPECT_EQ(ExtensionIndex::kEmptyExt, FileNameToExtensionIndex(u""));
30
31   // File name with an extension which contains non-ASCII characters.
32   EXPECT_EQ(ExtensionIndex::kOtherExt, FileNameToExtensionIndex(u"file.你好"));
33
34   // File name which ends with a dot.
35   EXPECT_EQ(ExtensionIndex::kOtherExt, FileNameToExtensionIndex(u"file."));
36 }
37
38 }  // namespace chrome_pdf