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

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_unittest.cc

Issue 10265022: Moving extensions inside chrome/browser/extensions/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/values.h" 5 #include "base/values.h"
6 #include "chrome/browser/extensions/extension_omnibox_api.h" 6 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/platform_test.h" 8 #include "testing/platform_test.h"
9 9
10 namespace extensions {
11
10 namespace { 12 namespace {
11 13
12 const int kNone = ACMatchClassification::NONE; 14 const int kNone = ACMatchClassification::NONE;
13 const int kUrl = ACMatchClassification::URL; 15 const int kUrl = ACMatchClassification::URL;
14 const int kMatch = ACMatchClassification::MATCH; 16 const int kMatch = ACMatchClassification::MATCH;
15 const int kDim = ACMatchClassification::DIM; 17 const int kDim = ACMatchClassification::DIM;
16 18
17 void AppendStyle(const std::string& type, 19 void AppendStyle(const std::string& type,
18 int offset, int length, 20 int offset, int length,
19 ListValue* styles) { 21 ListValue* styles) {
(...skipping 27 matching lines...) Expand all
47 AppendStyle("match", 1, 4, &styles_value); 49 AppendStyle("match", 1, 4, &styles_value);
48 AppendStyle("dim", 6, 3, &styles_value); 50 AppendStyle("dim", 6, 3, &styles_value);
49 51
50 ACMatchClassifications styles_expected; 52 ACMatchClassifications styles_expected;
51 styles_expected.push_back(ACMatchClassification(0, kNone)); 53 styles_expected.push_back(ACMatchClassification(0, kNone));
52 styles_expected.push_back(ACMatchClassification(1, kMatch)); 54 styles_expected.push_back(ACMatchClassification(1, kMatch));
53 styles_expected.push_back(ACMatchClassification(5, kNone)); 55 styles_expected.push_back(ACMatchClassification(5, kNone));
54 styles_expected.push_back(ACMatchClassification(6, kDim)); 56 styles_expected.push_back(ACMatchClassification(6, kDim));
55 styles_expected.push_back(ACMatchClassification(9, kNone)); 57 styles_expected.push_back(ACMatchClassification(9, kNone));
56 58
57 ExtensionOmniboxSuggestion suggestions; 59 extensions::ExtensionOmniboxSuggestion suggestions;
Matt Perry 2012/05/01 01:23:21 This should be unnecessary since this file is in t
vabr (Chromium) 2012/05/01 02:06:50 Done.
58 suggestions.description.resize(10); 60 suggestions.description.resize(10);
59 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value)); 61 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
60 CompareClassification(styles_expected, suggestions.description_styles); 62 CompareClassification(styles_expected, suggestions.description_styles);
61 63
62 // Same input, but swap the order. Ensure it still works. 64 // Same input, but swap the order. Ensure it still works.
63 styles_value.Clear(); 65 styles_value.Clear();
64 AppendStyle("dim", 6, 3, &styles_value); 66 AppendStyle("dim", 6, 3, &styles_value);
65 AppendStyle("match", 1, 4, &styles_value); 67 AppendStyle("match", 1, 4, &styles_value);
66 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value)); 68 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
67 CompareClassification(styles_expected, suggestions.description_styles); 69 CompareClassification(styles_expected, suggestions.description_styles);
(...skipping 15 matching lines...) Expand all
83 AppendStyle("dim", 1, 2, &styles_value); 85 AppendStyle("dim", 1, 2, &styles_value);
84 86
85 ACMatchClassifications styles_expected; 87 ACMatchClassifications styles_expected;
86 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch)); 88 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch));
87 styles_expected.push_back(ACMatchClassification(1, kUrl | kMatch | kDim)); 89 styles_expected.push_back(ACMatchClassification(1, kUrl | kMatch | kDim));
88 styles_expected.push_back(ACMatchClassification(3, kUrl | kMatch)); 90 styles_expected.push_back(ACMatchClassification(3, kUrl | kMatch));
89 styles_expected.push_back(ACMatchClassification(4, kUrl)); 91 styles_expected.push_back(ACMatchClassification(4, kUrl));
90 styles_expected.push_back(ACMatchClassification(5, kNone)); 92 styles_expected.push_back(ACMatchClassification(5, kNone));
91 styles_expected.push_back(ACMatchClassification(9, kMatch | kDim)); 93 styles_expected.push_back(ACMatchClassification(9, kMatch | kDim));
92 94
93 ExtensionOmniboxSuggestion suggestions; 95 extensions::ExtensionOmniboxSuggestion suggestions;
94 suggestions.description.resize(10); 96 suggestions.description.resize(10);
95 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value)); 97 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
96 CompareClassification(styles_expected, suggestions.description_styles); 98 CompareClassification(styles_expected, suggestions.description_styles);
97 99
98 // Try moving the "dim/match" style pair at offset 9. Output should be the 100 // Try moving the "dim/match" style pair at offset 9. Output should be the
99 // same. 101 // same.
100 styles_value.Clear(); 102 styles_value.Clear();
101 AppendStyle("url", 0, 5, &styles_value); 103 AppendStyle("url", 0, 5, &styles_value);
102 AppendStyle("match", 0, 4, &styles_value); 104 AppendStyle("match", 0, 4, &styles_value);
103 AppendStyle("dim", 9, 2, &styles_value); 105 AppendStyle("dim", 9, 2, &styles_value);
(...skipping 15 matching lines...) Expand all
119 AppendStyle("url", 0, 5, &styles_value); 121 AppendStyle("url", 0, 5, &styles_value);
120 AppendStyle("match", 0, 5, &styles_value); 122 AppendStyle("match", 0, 5, &styles_value);
121 AppendStyle("match", 0, 3, &styles_value); 123 AppendStyle("match", 0, 3, &styles_value);
122 AppendStyle("dim", 2, 3, &styles_value); 124 AppendStyle("dim", 2, 3, &styles_value);
123 AppendStyle("dim", 0, 3, &styles_value); 125 AppendStyle("dim", 0, 3, &styles_value);
124 126
125 ACMatchClassifications styles_expected; 127 ACMatchClassifications styles_expected;
126 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch | kDim)); 128 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch | kDim));
127 styles_expected.push_back(ACMatchClassification(5, kNone)); 129 styles_expected.push_back(ACMatchClassification(5, kNone));
128 130
129 ExtensionOmniboxSuggestion suggestions; 131 extensions::ExtensionOmniboxSuggestion suggestions;
130 suggestions.description.resize(10); 132 suggestions.description.resize(10);
131 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value)); 133 EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
132 CompareClassification(styles_expected, suggestions.description_styles); 134 CompareClassification(styles_expected, suggestions.description_styles);
133 } 135 }
136
137 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698