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

Side by Side Diff: printing/printing_utils_unittest.cc

Issue 1212883003: Include user email into document title before spooling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tue Jul 7 10:19:02 PDT 2015 Created 5 years, 5 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
« no previous file with comments | « printing/printing_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "printing/printing_utils.h" 6 #include "printing/printing_utils.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace printing { 9 namespace printing {
10 10
11 std::string Simplify(const char* title) { 11 namespace {
12 return base::UTF16ToUTF8(SimplifyDocumentTitle(base::ASCIIToUTF16(title))); 12
13 const size_t kTestLength = 8;
14
15 std::string Simplify(const std::string& title) {
16 return base::UTF16ToUTF8(
17 SimplifyDocumentTitleWithLength(base::UTF8ToUTF16(title), kTestLength));
13 } 18 }
14 19
20 std::string Format(const std::string& owner, const std::string& title) {
21 return base::UTF16ToUTF8(FormatDocumentTitleWithOwnerAndLength(
22 base::UTF8ToUTF16(owner), base::UTF8ToUTF16(title), kTestLength));
23 }
24
25 } // namespace
26
15 TEST(PrintingUtilsTest, SimplifyDocumentTitle) { 27 TEST(PrintingUtilsTest, SimplifyDocumentTitle) {
16 EXPECT_STREQ("", Simplify("").c_str()); 28 EXPECT_EQ("", Simplify(""));
17 EXPECT_STREQ("Long string. Long string...ng string. Long string.", 29 EXPECT_EQ("abcdefgh", Simplify("abcdefgh"));
18 Simplify("Long string. Long string. Long string. Long string. " 30 EXPECT_EQ("abc...ij", Simplify("abcdefghij"));
19 "Long string. Long string. Long string.").c_str()); 31 EXPECT_EQ("Controls", Simplify("C\ron\nt\15rols"));
20 EXPECT_STREQ("Control Characters", 32 EXPECT_EQ("", Simplify("\n\r\n\r\t\r"));
21 Simplify("C\ron\ntrol Charac\15ters").c_str()); 33 }
22 EXPECT_STREQ("", Simplify("\n\r\n\r\t\r").c_str()); 34
35 TEST(PrintingUtilsTest, FormatDocumentTitleWithOwner) {
36 EXPECT_EQ(": ", Format("", ""));
37 EXPECT_EQ("abc: ", Format("abc", ""));
38 EXPECT_EQ(": 123", Format("", "123"));
39 EXPECT_EQ("abc: 123", Format("abc", "123"));
40 EXPECT_EQ("abc: 0.9", Format("abc", "0123456789"));
41 EXPECT_EQ("ab...j: ", Format("abcdefghij", "123"));
42 EXPECT_EQ("ab...j: ", Format("abcdefghij", "0123456789"));
23 } 43 }
24 44
25 } // namespace printing 45 } // namespace printing
26 46
OLDNEW
« no previous file with comments | « printing/printing_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698