Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / search / tokenized_string_unittest.cc
blob64fb8eee4de80fd9b0c10a41f5642ce4a13e033f
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 "ui/app_list/search/tokenized_string.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace app_list {
11 namespace test {
13 namespace {
15 base::string16 GetContent(const TokenizedString& tokenized) {
16 const TokenizedString::Tokens& tokens = tokenized.tokens();
17 const TokenizedString::Mappings& mappings = tokenized.mappings();
19 base::string16 str;
20 for (size_t i = 0; i < tokens.size(); ++i) {
21 if (i > 0)
22 str += ' ';
23 str += tokens[i];
24 str += base::UTF8ToUTF16(mappings[i].ToString());
26 return str;
29 } // namespace
31 TEST(TokenizedStringTest, Empty) {
32 base::string16 empty;
33 TokenizedString tokens(empty);
34 EXPECT_EQ(base::string16(), GetContent(tokens));
37 TEST(TokenizedStringTest, Basic) {
39 base::string16 text(base::UTF8ToUTF16("ScratchPad"));
40 TokenizedString tokens(text);
41 EXPECT_EQ(base::UTF8ToUTF16("scratch{0,7} pad{7,10}"),
42 GetContent(tokens));
45 base::string16 text(base::UTF8ToUTF16("Chess2.0"));
46 TokenizedString tokens(text);
47 EXPECT_EQ(base::UTF8ToUTF16("chess{0,5} 2.0{5,8}"),
48 GetContent(tokens));
51 base::string16 text(base::UTF8ToUTF16("Cut the rope"));
52 TokenizedString tokens(text);
53 EXPECT_EQ(base::UTF8ToUTF16("cut{0,3} the{4,7} rope{8,12}"),
54 GetContent(tokens));
57 base::string16 text(base::UTF8ToUTF16("AutoCAD WS"));
58 TokenizedString tokens(text);
59 EXPECT_EQ(base::UTF8ToUTF16("auto{0,4} cad{4,7} ws{8,10}"),
60 GetContent(tokens));
63 base::string16 text(base::UTF8ToUTF16("Great TweetDeck"));
64 TokenizedString tokens(text);
65 EXPECT_EQ(base::UTF8ToUTF16("great{0,5} tweet{6,11} deck{11,15}"),
66 GetContent(tokens));
69 base::string16 text(base::UTF8ToUTF16("Draw-It!"));
70 TokenizedString tokens(text);
71 EXPECT_EQ(base::UTF8ToUTF16("draw{0,4} it{5,7}"),
72 GetContent(tokens));
75 base::string16 text(base::UTF8ToUTF16("Faxing & Signing"));
76 TokenizedString tokens(text);
77 EXPECT_EQ(base::UTF8ToUTF16("faxing{0,6} signing{9,16}"),
78 GetContent(tokens));
81 base::string16 text(base::UTF8ToUTF16("!@#$%^&*()<<<**>>>"));
82 TokenizedString tokens(text);
83 EXPECT_EQ(base::UTF8ToUTF16(""),
84 GetContent(tokens));
88 } // namespace test
89 } // namespace app_list