summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_omnibox_unittest.cc
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 21:44:28 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 21:44:28 +0000
commit44254d57fc5ff8f96e3227d8c421819516470286 (patch)
tree21969ef09d5b522090104aeab2440d7c25c22fc7 /chrome/browser/extensions/extension_omnibox_unittest.cc
parent1a3efc6ae8008e83e1d5e909eac23fdb6600822a (diff)
downloadchromium_src-44254d57fc5ff8f96e3227d8c421819516470286.zip
chromium_src-44254d57fc5ff8f96e3227d8c421819516470286.tar.gz
chromium_src-44254d57fc5ff8f96e3227d8c421819516470286.tar.bz2
More changes to extension omnibox API for styles.
- Overlapping styles are now bitwise-ORed together (instead of replacing previous ones). - The "length" parameter for style ranges is optional and can be 0. BUG=63077,63078 TEST=covered by tests Review URL: http://codereview.chromium.org/5064001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66327 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_omnibox_unittest.cc')
-rw-r--r--chrome/browser/extensions/extension_omnibox_unittest.cc59
1 files changed, 24 insertions, 35 deletions
diff --git a/chrome/browser/extensions/extension_omnibox_unittest.cc b/chrome/browser/extensions/extension_omnibox_unittest.cc
index ca2d1e0..a358b18 100644
--- a/chrome/browser/extensions/extension_omnibox_unittest.cc
+++ b/chrome/browser/extensions/extension_omnibox_unittest.cc
@@ -9,6 +9,11 @@
namespace {
+const int kNone = ACMatchClassification::NONE;
+const int kUrl = ACMatchClassification::URL;
+const int kMatch = ACMatchClassification::MATCH;
+const int kDim = ACMatchClassification::DIM;
+
void AppendStyle(const std::string& type,
int offset, int length,
ListValue* styles) {
@@ -31,6 +36,7 @@ void CompareClassification(const ACMatchClassifications& expected,
} // namespace
// Test output key: n = character with no styling, d = dim, m = match, u = url
+// u = 1, m = 2, d = 4. u+d = 5, etc.
// 0123456789
// mmmm
@@ -42,16 +48,11 @@ TEST(ExtensionOmniboxTest, DescriptionStylesSimple) {
AppendStyle("dim", 6, 3, &styles_value);
ACMatchClassifications styles_expected;
- styles_expected.push_back(
- ACMatchClassification(0, ACMatchClassification::NONE));
- styles_expected.push_back(
- ACMatchClassification(1, ACMatchClassification::MATCH));
- styles_expected.push_back(
- ACMatchClassification(5, ACMatchClassification::NONE));
- styles_expected.push_back(
- ACMatchClassification(6, ACMatchClassification::DIM));
- styles_expected.push_back(
- ACMatchClassification(9, ACMatchClassification::NONE));
+ styles_expected.push_back(ACMatchClassification(0, kNone));
+ styles_expected.push_back(ACMatchClassification(1, kMatch));
+ styles_expected.push_back(ACMatchClassification(5, kNone));
+ styles_expected.push_back(ACMatchClassification(6, kDim));
+ styles_expected.push_back(ACMatchClassification(9, kNone));
ExtensionOmniboxSuggestion suggestions;
suggestions.description.resize(10);
@@ -67,13 +68,13 @@ TEST(ExtensionOmniboxTest, DescriptionStylesSimple) {
}
// 0123456789
-// uuuuuu
+// uuuuu
// + dd
// + mm
// + mmmm
// + dd
-// = mddmunnnnm
-TEST(ExtensionOmniboxTest, DescriptionStylesOverlap) {
+// = 3773unnnn66
+TEST(ExtensionOmniboxTest, DescriptionStylesCombine) {
ListValue styles_value;
AppendStyle("url", 0, 5, &styles_value);
AppendStyle("dim", 9, 2, &styles_value);
@@ -82,18 +83,12 @@ TEST(ExtensionOmniboxTest, DescriptionStylesOverlap) {
AppendStyle("dim", 1, 2, &styles_value);
ACMatchClassifications styles_expected;
- styles_expected.push_back(
- ACMatchClassification(0, ACMatchClassification::MATCH));
- styles_expected.push_back(
- ACMatchClassification(1, ACMatchClassification::DIM));
- styles_expected.push_back(
- ACMatchClassification(3, ACMatchClassification::MATCH));
- styles_expected.push_back(
- ACMatchClassification(4, ACMatchClassification::URL));
- styles_expected.push_back(
- ACMatchClassification(5, ACMatchClassification::NONE));
- styles_expected.push_back(
- ACMatchClassification(9, ACMatchClassification::MATCH));
+ styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch));
+ styles_expected.push_back(ACMatchClassification(1, kUrl | kMatch | kDim));
+ styles_expected.push_back(ACMatchClassification(3, kUrl | kMatch));
+ styles_expected.push_back(ACMatchClassification(4, kUrl));
+ styles_expected.push_back(ACMatchClassification(5, kNone));
+ styles_expected.push_back(ACMatchClassification(9, kMatch | kDim));
ExtensionOmniboxSuggestion suggestions;
suggestions.description.resize(10);
@@ -118,8 +113,8 @@ TEST(ExtensionOmniboxTest, DescriptionStylesOverlap) {
// + mmm
// + ddd
// + ddd
-// = dddddnnnnn
-TEST(ExtensionOmniboxTest, DescriptionStylesOverlap2) {
+// = 77777nnnnn
+TEST(ExtensionOmniboxTest, DescriptionStylesCombine2) {
ListValue styles_value;
AppendStyle("url", 0, 5, &styles_value);
AppendStyle("match", 0, 5, &styles_value);
@@ -127,15 +122,9 @@ TEST(ExtensionOmniboxTest, DescriptionStylesOverlap2) {
AppendStyle("dim", 2, 3, &styles_value);
AppendStyle("dim", 0, 3, &styles_value);
- // We don't merge adjacent identical styles, but the autocomplete system
- // doesn't mind.
ACMatchClassifications styles_expected;
- styles_expected.push_back(
- ACMatchClassification(0, ACMatchClassification::DIM));
- styles_expected.push_back(
- ACMatchClassification(3, ACMatchClassification::DIM));
- styles_expected.push_back(
- ACMatchClassification(5, ACMatchClassification::NONE));
+ styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch | kDim));
+ styles_expected.push_back(ACMatchClassification(5, kNone));
ExtensionOmniboxSuggestion suggestions;
suggestions.description.resize(10);