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

Side by Side Diff: chrome/browser/ui/app_list/search/tokenized_string_unittest.cc

Issue 120983002: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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/ui/app_list/search/tokenized_string.h" 5 #include "chrome/browser/ui/app_list/search/tokenized_string.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace app_list { 10 namespace app_list {
11 namespace test { 11 namespace test {
12 12
13 namespace { 13 namespace {
14 14
15 base::string16 GetContent(const TokenizedString& tokenized) { 15 base::string16 GetContent(const TokenizedString& tokenized) {
16 const TokenizedString::Tokens& tokens = tokenized.tokens(); 16 const TokenizedString::Tokens& tokens = tokenized.tokens();
17 const TokenizedString::Mappings& mappings = tokenized.mappings(); 17 const TokenizedString::Mappings& mappings = tokenized.mappings();
18 18
19 base::string16 str; 19 base::string16 str;
20 for (size_t i = 0; i < tokens.size(); ++i) { 20 for (size_t i = 0; i < tokens.size(); ++i) {
21 if (i > 0) 21 if (i > 0)
22 str += ' '; 22 str += ' ';
23 str += tokens[i]; 23 str += tokens[i];
24 str += UTF8ToUTF16(mappings[i].ToString()); 24 str += base::UTF8ToUTF16(mappings[i].ToString());
25 } 25 }
26 return str; 26 return str;
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 TEST(TokenizedStringTest, Empty) { 31 TEST(TokenizedStringTest, Empty) {
32 base::string16 empty; 32 base::string16 empty;
33 TokenizedString tokens(empty); 33 TokenizedString tokens(empty);
34 EXPECT_EQ(base::string16(), GetContent(tokens)); 34 EXPECT_EQ(base::string16(), GetContent(tokens));
35 } 35 }
36 36
37 TEST(TokenizedStringTest, Basic) { 37 TEST(TokenizedStringTest, Basic) {
38 { 38 {
39 base::string16 text(UTF8ToUTF16("ScratchPad")); 39 base::string16 text(base::UTF8ToUTF16("ScratchPad"));
40 TokenizedString tokens(text); 40 TokenizedString tokens(text);
41 EXPECT_EQ(UTF8ToUTF16("scratch{0,7} pad{7,10}"), 41 EXPECT_EQ(base::UTF8ToUTF16("scratch{0,7} pad{7,10}"),
42 GetContent(tokens)); 42 GetContent(tokens));
43 } 43 }
44 { 44 {
45 base::string16 text(UTF8ToUTF16("Chess2.0")); 45 base::string16 text(base::UTF8ToUTF16("Chess2.0"));
46 TokenizedString tokens(text); 46 TokenizedString tokens(text);
47 EXPECT_EQ(UTF8ToUTF16("chess{0,5} 2.0{5,8}"), 47 EXPECT_EQ(base::UTF8ToUTF16("chess{0,5} 2.0{5,8}"),
48 GetContent(tokens)); 48 GetContent(tokens));
49 } 49 }
50 { 50 {
51 base::string16 text(UTF8ToUTF16("Cut the rope")); 51 base::string16 text(base::UTF8ToUTF16("Cut the rope"));
52 TokenizedString tokens(text); 52 TokenizedString tokens(text);
53 EXPECT_EQ(UTF8ToUTF16("cut{0,3} the{4,7} rope{8,12}"), 53 EXPECT_EQ(base::UTF8ToUTF16("cut{0,3} the{4,7} rope{8,12}"),
54 GetContent(tokens)); 54 GetContent(tokens));
55 } 55 }
56 { 56 {
57 base::string16 text(UTF8ToUTF16("AutoCAD WS")); 57 base::string16 text(base::UTF8ToUTF16("AutoCAD WS"));
58 TokenizedString tokens(text); 58 TokenizedString tokens(text);
59 EXPECT_EQ(UTF8ToUTF16("auto{0,4} cad{4,7} ws{8,10}"), 59 EXPECT_EQ(base::UTF8ToUTF16("auto{0,4} cad{4,7} ws{8,10}"),
60 GetContent(tokens)); 60 GetContent(tokens));
61 } 61 }
62 { 62 {
63 base::string16 text(UTF8ToUTF16("Great TweetDeck")); 63 base::string16 text(base::UTF8ToUTF16("Great TweetDeck"));
64 TokenizedString tokens(text); 64 TokenizedString tokens(text);
65 EXPECT_EQ(UTF8ToUTF16("great{0,5} tweet{6,11} deck{11,15}"), 65 EXPECT_EQ(base::UTF8ToUTF16("great{0,5} tweet{6,11} deck{11,15}"),
66 GetContent(tokens)); 66 GetContent(tokens));
67 } 67 }
68 { 68 {
69 base::string16 text(UTF8ToUTF16("Draw-It!")); 69 base::string16 text(base::UTF8ToUTF16("Draw-It!"));
70 TokenizedString tokens(text); 70 TokenizedString tokens(text);
71 EXPECT_EQ(UTF8ToUTF16("draw{0,4} it{5,7}"), 71 EXPECT_EQ(base::UTF8ToUTF16("draw{0,4} it{5,7}"),
72 GetContent(tokens)); 72 GetContent(tokens));
73 } 73 }
74 { 74 {
75 base::string16 text(UTF8ToUTF16("Faxing & Signing")); 75 base::string16 text(base::UTF8ToUTF16("Faxing & Signing"));
76 TokenizedString tokens(text); 76 TokenizedString tokens(text);
77 EXPECT_EQ(UTF8ToUTF16("faxing{0,6} signing{9,16}"), 77 EXPECT_EQ(base::UTF8ToUTF16("faxing{0,6} signing{9,16}"),
78 GetContent(tokens)); 78 GetContent(tokens));
79 } 79 }
80 { 80 {
81 base::string16 text(UTF8ToUTF16("!@#$%^&*()<<<**>>>")); 81 base::string16 text(base::UTF8ToUTF16("!@#$%^&*()<<<**>>>"));
82 TokenizedString tokens(text); 82 TokenizedString tokens(text);
83 EXPECT_EQ(UTF8ToUTF16(""), 83 EXPECT_EQ(base::UTF8ToUTF16(""),
84 GetContent(tokens)); 84 GetContent(tokens));
85 } 85 }
86 } 86 }
87 87
88 } // namespace test 88 } // namespace test
89 } // namespace app_list 89 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698