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

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

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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
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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "net/base/escape.h" 13 #include "net/base/escape.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace file_manager { 16 namespace file_manager {
17 namespace util { 17 namespace util {
18 namespace { 18 namespace {
19 19
20 // Pretty print the JSON escaped in the query string. 20 // Pretty print the JSON escaped in the query string.
21 std::string PrettyPrintEscapedJson(const std::string& query) { 21 std::string PrettyPrintEscapedJson(const std::string& query) {
22 const std::string json = net::UnescapeURLComponent( 22 const std::string json = net::UnescapeURLComponent(
23 query, net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); 23 query, net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
24 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); 24 scoped_ptr<base::Value> value(base::JSONReader::Read(json));
25 std::string pretty_json; 25 std::string pretty_json;
26 base::JSONWriter::WriteWithOptions(value.get(), 26 base::JSONWriter::WriteWithOptions(
27 base::JSONWriter::OPTIONS_PRETTY_PRINT, 27 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &pretty_json);
28 &pretty_json);
29 return pretty_json; 28 return pretty_json;
30 } 29 }
31 30
32 TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrl) { 31 TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrl) {
33 EXPECT_EQ("chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main.html", 32 EXPECT_EQ("chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main.html",
34 GetFileManagerMainPageUrl().spec()); 33 GetFileManagerMainPageUrl().spec());
35 } 34 }
36 35
37 TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) { 36 TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) {
38 const GURL url = GetFileManagerMainPageUrlWithParams( 37 const GURL url = GetFileManagerMainPageUrlWithParams(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 " \"extensions\": [ \"txt\" ],\n" 118 " \"extensions\": [ \"txt\" ],\n"
120 " \"selected\": false\n" 119 " \"selected\": false\n"
121 " } ]\n" 120 " } ]\n"
122 "}\n", 121 "}\n",
123 PrettyPrintEscapedJson(url.query())); 122 PrettyPrintEscapedJson(url.query()));
124 } 123 }
125 124
126 } // namespace 125 } // namespace
127 } // namespace util 126 } // namespace util
128 } // namespace file_manager 127 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698