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

Side by Side Diff: chrome/browser/autocomplete/in_memory_url_index_unittest.cc

Issue 1197243004: Replace some Tokenize calls with SplitString. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <fstream> 6 #include <fstream>
7 7
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/i18n/case_conversion.h" 12 #include "base/i18n/case_conversion.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 20 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/history/history_service_factory.h" 21 #include "chrome/browser/history/history_service_factory.h"
21 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
22 #include "chrome/test/base/history_index_restore_observer.h" 23 #include "chrome/test/base/history_index_restore_observer.h"
23 #include "chrome/test/base/testing_profile.h" 24 #include "chrome/test/base/testing_profile.h"
24 #include "components/bookmarks/test/bookmark_test_helpers.h" 25 #include "components/bookmarks/test/bookmark_test_helpers.h"
25 #include "components/history/core/browser/history_backend.h" 26 #include "components/history/core/browser/history_backend.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void StringToTerms(const char* search_string, 62 void StringToTerms(const char* search_string,
62 size_t cursor_position, 63 size_t cursor_position,
63 base::string16* lower_string, 64 base::string16* lower_string,
64 String16Vector* lower_terms) { 65 String16Vector* lower_terms) {
65 *lower_string = base::i18n::ToLower(ASCIIToUTF16(search_string)); 66 *lower_string = base::i18n::ToLower(ASCIIToUTF16(search_string));
66 if ((cursor_position != kInvalid) && 67 if ((cursor_position != kInvalid) &&
67 (cursor_position < lower_string->length()) && (cursor_position > 0)) { 68 (cursor_position < lower_string->length()) && (cursor_position > 0)) {
68 lower_string->insert(cursor_position, base::ASCIIToUTF16(" ")); 69 lower_string->insert(cursor_position, base::ASCIIToUTF16(" "));
69 } 70 }
70 71
71 Tokenize(*lower_string, base::kWhitespaceUTF16, lower_terms); 72 *lower_terms = base::SplitString(*lower_string, base::kWhitespaceUTF16,
73 base::KEEP_WHITESPACE,
74 base::SPLIT_WANT_NONEMPTY);
72 } 75 }
73 76
74 } // namespace 77 } // namespace
75 78
76 // ----------------------------------------------------------------------------- 79 // -----------------------------------------------------------------------------
77 80
78 // Observer class so the unit tests can wait while the cache is being saved. 81 // Observer class so the unit tests can wait while the cache is being saved.
79 class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver { 82 class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver {
80 public: 83 public:
81 explicit CacheFileSaverObserver(const base::Closure& task); 84 explicit CacheFileSaverObserver(const base::Closure& task);
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 ASSERT_TRUE(GetCacheFilePath(&full_file_path)); 1356 ASSERT_TRUE(GetCacheFilePath(&full_file_path));
1354 std::vector<base::FilePath::StringType> actual_parts; 1357 std::vector<base::FilePath::StringType> actual_parts;
1355 full_file_path.GetComponents(&actual_parts); 1358 full_file_path.GetComponents(&actual_parts);
1356 ASSERT_EQ(expected_parts.size(), actual_parts.size()); 1359 ASSERT_EQ(expected_parts.size(), actual_parts.size());
1357 size_t count = expected_parts.size(); 1360 size_t count = expected_parts.size();
1358 for (size_t i = 0; i < count; ++i) 1361 for (size_t i = 0; i < count; ++i)
1359 EXPECT_EQ(expected_parts[i], actual_parts[i]); 1362 EXPECT_EQ(expected_parts[i], actual_parts[i]);
1360 // Must clear the history_dir_ to satisfy the dtor's DCHECK. 1363 // Must clear the history_dir_ to satisfy the dtor's DCHECK.
1361 set_history_dir(base::FilePath()); 1364 set_history_dir(base::FilePath());
1362 } 1365 }
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_memory.cc ('k') | chrome/browser/chromeos/events/event_rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698