Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: chrome/browser/chromeos/file_manager/url_util_unittest.cc

Issue 144783002: Simplify directory initialization in Files app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/file_manager/url_util.h" 5 #include "chrome/browser/chromeos/file_manager/url_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 FILE_PATH_LITERAL("txt")); 49 FILE_PATH_LITERAL("txt"));
50 EXPECT_EQ("chrome-extension", url.scheme()); 50 EXPECT_EQ("chrome-extension", url.scheme());
51 EXPECT_EQ("hhaomjibdihmijegdhdafkllkbggdgoj", url.host()); 51 EXPECT_EQ("hhaomjibdihmijegdhdafkllkbggdgoj", url.host());
52 EXPECT_EQ("/main.html", url.path()); 52 EXPECT_EQ("/main.html", url.path());
53 // Confirm that "%20" is used instead of "+" in the query. 53 // Confirm that "%20" is used instead of "+" in the query.
54 EXPECT_TRUE(url.query().find("+") == std::string::npos); 54 EXPECT_TRUE(url.query().find("+") == std::string::npos);
55 EXPECT_TRUE(url.query().find("%20") != std::string::npos); 55 EXPECT_TRUE(url.query().find("%20") != std::string::npos);
56 // The escaped query is hard to read. Pretty print the escaped JSON. 56 // The escaped query is hard to read. Pretty print the escaped JSON.
57 EXPECT_EQ("{\n" 57 EXPECT_EQ("{\n"
58 " \"defaultExtension\": \"txt\",\n" 58 " \"defaultExtension\": \"txt\",\n"
59 " \"defaultPath\": \"foo.txt\",\n" 59 " \"currentDirectoryPath\": \"/Downloads\",\n"
60 " \"selectionPath\": \"/Downloads/foo.txt\",\n"
60 " \"shouldReturnLocalPath\": true,\n" 61 " \"shouldReturnLocalPath\": true,\n"
62 " \"targetName\": \"foo.txt\",\n"
61 " \"title\": \"some title\",\n" 63 " \"title\": \"some title\",\n"
62 " \"type\": \"open-file\"\n" 64 " \"type\": \"open-file\"\n"
63 "}\n", 65 "}\n",
64 PrettyPrintEscapedJson(url.query())); 66 PrettyPrintEscapedJson(url.query()));
65 } 67 }
66 68
67 TEST(FileManagerUrlUtilTest, 69 TEST(FileManagerUrlUtilTest,
68 GetFileManagerMainPageUrlWithParams_WithFileTypes) { 70 GetFileManagerMainPageUrlWithParams_WithFileTypes) {
69 // Create a FileTypeInfo which looks like: 71 // Create a FileTypeInfo which looks like:
70 // extensions: [["htm", "html"], ["txt"]] 72 // extensions: [["htm", "html"], ["txt"]]
71 // descriptions: ["HTML", "TEXT"] 73 // descriptions: ["HTML", "TEXT"]
72 ui::SelectFileDialog::FileTypeInfo file_types; 74 ui::SelectFileDialog::FileTypeInfo file_types;
73 file_types.extensions.push_back(std::vector<base::FilePath::StringType>()); 75 file_types.extensions.push_back(std::vector<base::FilePath::StringType>());
74 file_types.extensions[0].push_back(FILE_PATH_LITERAL("htm")); 76 file_types.extensions[0].push_back(FILE_PATH_LITERAL("htm"));
75 file_types.extensions[0].push_back(FILE_PATH_LITERAL("html")); 77 file_types.extensions[0].push_back(FILE_PATH_LITERAL("html"));
76 file_types.extensions.push_back(std::vector<base::FilePath::StringType>()); 78 file_types.extensions.push_back(std::vector<base::FilePath::StringType>());
77 file_types.extensions[1].push_back(FILE_PATH_LITERAL("txt")); 79 file_types.extensions[1].push_back(FILE_PATH_LITERAL("txt"));
78 file_types.extension_description_overrides.push_back( 80 file_types.extension_description_overrides.push_back(
79 base::UTF8ToUTF16("HTML")); 81 base::UTF8ToUTF16("HTML"));
80 file_types.extension_description_overrides.push_back( 82 file_types.extension_description_overrides.push_back(
81 base::UTF8ToUTF16("TEXT")); 83 base::UTF8ToUTF16("TEXT"));
82 // "shouldReturnLocalPath" will be false if drive is supported. 84 // "shouldReturnLocalPath" will be false if drive is supported.
83 file_types.support_drive = true; 85 file_types.support_drive = true;
84 86
85 const GURL url = GetFileManagerMainPageUrlWithParams( 87 const GURL url = GetFileManagerMainPageUrlWithParams(
86 ui::SelectFileDialog::SELECT_OPEN_FILE, 88 ui::SelectFileDialog::SELECT_OPEN_FILE,
87 base::UTF8ToUTF16("some title"), 89 base::UTF8ToUTF16("some title"),
88 base::FilePath::FromUTF8Unsafe("foo.txt"), 90 base::FilePath::FromUTF8Unsafe("/Downloads/foo.txt"),
89 &file_types, 91 &file_types,
90 1, // The file type index is 1-based. 92 1, // The file type index is 1-based.
91 FILE_PATH_LITERAL("txt")); 93 FILE_PATH_LITERAL("txt"));
92 EXPECT_EQ("chrome-extension", url.scheme()); 94 EXPECT_EQ("chrome-extension", url.scheme());
93 EXPECT_EQ("hhaomjibdihmijegdhdafkllkbggdgoj", url.host()); 95 EXPECT_EQ("hhaomjibdihmijegdhdafkllkbggdgoj", url.host());
94 EXPECT_EQ("/main.html", url.path()); 96 EXPECT_EQ("/main.html", url.path());
95 // Confirm that "%20" is used instead of "+" in the query. 97 // Confirm that "%20" is used instead of "+" in the query.
96 EXPECT_TRUE(url.query().find("+") == std::string::npos); 98 EXPECT_TRUE(url.query().find("+") == std::string::npos);
97 EXPECT_TRUE(url.query().find("%20") != std::string::npos); 99 EXPECT_TRUE(url.query().find("%20") != std::string::npos);
98 // The escaped query is hard to read. Pretty print the escaped JSON. 100 // The escaped query is hard to read. Pretty print the escaped JSON.
99 EXPECT_EQ("{\n" 101 EXPECT_EQ("{\n"
100 " \"defaultExtension\": \"txt\",\n" 102 " \"defaultExtension\": \"txt\",\n"
101 " \"defaultPath\": \"foo.txt\",\n" 103 " \"currentDirectoryPath\": \"/Downloads\",\n"
104 " \"selectionPath\": \"/Downloads/foo.txt\",\n"
102 " \"includeAllFiles\": false,\n" 105 " \"includeAllFiles\": false,\n"
103 " \"shouldReturnLocalPath\": false,\n" 106 " \"shouldReturnLocalPath\": false,\n"
107 " \"targetName\": \"foo.txt\",\n"
104 " \"title\": \"some title\",\n" 108 " \"title\": \"some title\",\n"
105 " \"type\": \"open-file\",\n" 109 " \"type\": \"open-file\",\n"
106 " \"typeList\": [ {\n" 110 " \"typeList\": [ {\n"
107 " \"description\": \"HTML\",\n" 111 " \"description\": \"HTML\",\n"
108 " \"extensions\": [ \"htm\", \"html\" ],\n" 112 " \"extensions\": [ \"htm\", \"html\" ],\n"
109 " \"selected\": true\n" 113 " \"selected\": true\n"
110 " }, {\n" 114 " }, {\n"
111 " \"description\": \"TEXT\",\n" 115 " \"description\": \"TEXT\",\n"
112 " \"extensions\": [ \"txt\" ],\n" 116 " \"extensions\": [ \"txt\" ],\n"
113 " \"selected\": false\n" 117 " \"selected\": false\n"
114 " } ]\n" 118 " } ]\n"
115 "}\n", 119 "}\n",
116 PrettyPrintEscapedJson(url.query())); 120 PrettyPrintEscapedJson(url.query()));
117 } 121 }
118 122
119 } // namespace 123 } // namespace
120 } // namespace util 124 } // namespace util
121 } // namespace file_manager 125 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698