Update V8 to version 4.7.24.
[chromium-blink-merge.git] / printing / printing_utils_unittest.cc
blob331451d6b16c2852ed7f619f5ffb090c0e9353f6
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
3 // found in the LICENSE file.
5 #include "base/strings/utf_string_conversions.h"
6 #include "printing/printing_utils.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace printing {
11 namespace {
13 const size_t kTestLength = 8;
15 std::string Simplify(const std::string& title) {
16 return base::UTF16ToUTF8(
17 SimplifyDocumentTitleWithLength(base::UTF8ToUTF16(title), kTestLength));
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));
25 } // namespace
27 TEST(PrintingUtilsTest, SimplifyDocumentTitle) {
28 EXPECT_EQ("", Simplify(""));
29 EXPECT_EQ("abcdefgh", Simplify("abcdefgh"));
30 EXPECT_EQ("abc...ij", Simplify("abcdefghij"));
31 EXPECT_EQ("Controls", Simplify("C\ron\nt\15rols"));
32 EXPECT_EQ("", Simplify("\n\r\n\r\t\r"));
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"));
45 } // namespace printing