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

Side by Side Diff: chrome/browser/chromeos/drive/search_metadata_unittest.cc

Issue 15945004: Case-insensitive search for non-ASCII characters in auto-complete of Drive files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 7 years, 6 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
« no previous file with comments | « chrome/browser/chromeos/drive/search_metadata.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chromeos/drive/search_metadata.h" 5 #include "chrome/browser/chromeos/drive/search_metadata.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 24 matching lines...) Expand all
35 id_counter_(0), 35 id_counter_(0),
36 last_accessed_counter_(last_accessed_base) {} 36 last_accessed_counter_(last_accessed_base) {}
37 37
38 // Obtains resource ID that is consists of the prefix and a sequential 38 // Obtains resource ID that is consists of the prefix and a sequential
39 // number. 39 // number.
40 std::string GetId() const { 40 std::string GetId() const {
41 return base::StringPrintf("%s%d", prefix_.c_str(), id_counter_); 41 return base::StringPrintf("%s%d", prefix_.c_str(), id_counter_);
42 } 42 }
43 43
44 // Obtains the fake last accessed time that is sequential number following 44 // Obtains the fake last accessed time that is sequential number following
45 // |last_accessed_base| specified at the construcor. 45 // |last_accessed_base| specified at the constructor.
46 int64 GetLastAccessed() const { 46 int64 GetLastAccessed() const {
47 return last_accessed_counter_; 47 return last_accessed_counter_;
48 } 48 }
49 49
50 // Advances counters to generate the next ID and last accessed time. 50 // Advances counters to generate the next ID and last accessed time.
51 void Advance() { 51 void Advance() {
52 ++id_counter_; 52 ++id_counter_;
53 ++last_accessed_counter_; 53 ++last_accessed_counter_;
54 } 54 }
55 55
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 567
568 TEST(SearchMetadataSimpleTest, FindAndHighlight_InTheMiddle) { 568 TEST(SearchMetadataSimpleTest, FindAndHighlight_InTheMiddle) {
569 std::string highlighted_text; 569 std::string highlighted_text;
570 EXPECT_TRUE(FindAndHighlight("yo hello, world", "hello", &highlighted_text)); 570 EXPECT_TRUE(FindAndHighlight("yo hello, world", "hello", &highlighted_text));
571 EXPECT_EQ("yo <b>hello</b>, world", highlighted_text); 571 EXPECT_EQ("yo <b>hello</b>, world", highlighted_text);
572 } 572 }
573 573
574 TEST(SearchMetadataSimpleTest, FindAndHighlight_MultipeMatches) { 574 TEST(SearchMetadataSimpleTest, FindAndHighlight_MultipeMatches) {
575 std::string highlighted_text; 575 std::string highlighted_text;
576 EXPECT_TRUE(FindAndHighlight("yoyoyoyoy", "yoy", &highlighted_text)); 576 EXPECT_TRUE(FindAndHighlight("yoyoyoyoy", "yoy", &highlighted_text));
577 EXPECT_EQ("<b>yoy</b>o<b>yoy</b>oy", highlighted_text); 577 // Only the first match is highlighted.
578 EXPECT_EQ("<b>yoy</b>oyoyoy", highlighted_text);
578 } 579 }
579 580
580 TEST(SearchMetadataSimpleTest, FindAndHighlight_IgnoreCase) { 581 TEST(SearchMetadataSimpleTest, FindAndHighlight_IgnoreCase) {
581 std::string highlighted_text; 582 std::string highlighted_text;
582 EXPECT_TRUE(FindAndHighlight("HeLLo", "hello", &highlighted_text)); 583 EXPECT_TRUE(FindAndHighlight("HeLLo", "hello", &highlighted_text));
583 EXPECT_EQ("<b>HeLLo</b>", highlighted_text); 584 EXPECT_EQ("<b>HeLLo</b>", highlighted_text);
584 } 585 }
585 586
587 TEST(SearchMetadataSimpleTest, FindAndHighlight_IgnoreCaseNonASCII) {
588 std::string highlighted_text;
589
590 // Case and accent ignorance in Greek. Find "socra" in "Socra'tes".
591 EXPECT_TRUE(FindAndHighlight(
592 "\xCE\xA3\xCF\x89\xCE\xBA\xCF\x81\xCE\xAC\xCF\x84\xCE\xB7\xCF\x82",
593 "\xCF\x83\xCF\x89\xCE\xBA\xCF\x81\xCE\xB1", &highlighted_text));
594 EXPECT_EQ(
595 "<b>\xCE\xA3\xCF\x89\xCE\xBA\xCF\x81\xCE\xAC</b>\xCF\x84\xCE\xB7\xCF\x82",
596 highlighted_text);
597
598 // In Japanese characters.
599 // Find Hiragana "pi" + "(small)ya" in Katakana "hi" + semi-voiced-mark + "ya"
600 EXPECT_TRUE(FindAndHighlight(
601 "\xE3\x81\xB2\xE3\x82\x9A\xE3\x82\x83\xE3\x83\xBC",
602 "\xE3\x83\x94\xE3\x83\xA4",
603 &highlighted_text));
604 EXPECT_EQ(
605 "<b>\xE3\x81\xB2\xE3\x82\x9A\xE3\x82\x83</b>\xE3\x83\xBC",
606 highlighted_text);
607 }
608
586 TEST(SearchMetadataSimpleTest, FindAndHighlight_MetaChars) { 609 TEST(SearchMetadataSimpleTest, FindAndHighlight_MetaChars) {
587 std::string highlighted_text; 610 std::string highlighted_text;
588 EXPECT_TRUE(FindAndHighlight("<hello>", "hello", &highlighted_text)); 611 EXPECT_TRUE(FindAndHighlight("<hello>", "hello", &highlighted_text));
589 EXPECT_EQ("&lt;<b>hello</b>&gt;", highlighted_text); 612 EXPECT_EQ("&lt;<b>hello</b>&gt;", highlighted_text);
590 } 613 }
591 614
592 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) { 615 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) {
593 std::string highlighted_text; 616 std::string highlighted_text;
594 EXPECT_TRUE(FindAndHighlight("a&b&c&d", "b&c", &highlighted_text)); 617 EXPECT_TRUE(FindAndHighlight("a&b&c&d", "b&c", &highlighted_text));
595 EXPECT_EQ("a&amp;<b>b&amp;c</b>&amp;d", highlighted_text); 618 EXPECT_EQ("a&amp;<b>b&amp;c</b>&amp;d", highlighted_text);
596 } 619 }
597 620
598 } // namespace internal 621 } // namespace internal
599 } // namespace drive 622 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/search_metadata.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698