Upload upstream chromium 76.0.3809.146
[platform/framework/web/chromium-efl.git] / pdf / out_of_process_instance_unittest.cc
1 // Copyright 2019 The Chromium Authors. All rights reserved.
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/out_of_process_instance.h"
6
7 #include <string>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace chrome_pdf {
12
13 TEST(OutOfProcessInstanceTest, GetFileNameFromUrl) {
14   EXPECT_EQ("b.pdf",
15             OutOfProcessInstance::GetFileNameFromUrl("https://test/a/b.pdf"));
16
17   // File extensions should be kept as-is.
18   EXPECT_EQ("b.hat",
19             OutOfProcessInstance::GetFileNameFromUrl("https://test/a/b.hat"));
20
21   // Most escaped characters should be unescaped.
22   EXPECT_EQ("a b.pdf", OutOfProcessInstance::GetFileNameFromUrl(
23                            "https://test/%61%20b.pdf"));
24
25   // Escaped file path delimiters and control codes should be replaced by a
26   // placeholder.
27   EXPECT_EQ("a_b_.pdf", OutOfProcessInstance::GetFileNameFromUrl(
28                             "https://test/a%2Fb%01.pdf"));
29
30   // UTF-8 characters, including ones left escaped by UnescapeURLComponent() for
31   // security reasons, are allowed in file paths.
32   EXPECT_EQ("\xF0\x9F\x94\x92", OutOfProcessInstance::GetFileNameFromUrl(
33                                     "https://test/%F0%9F%94%92"));
34 }
35
36 }  // namespace chrome_pdf