OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/bookmarks/browser/bookmark_index.h" | 5 #include "components/bookmarks/browser/bookmark_index.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 const char* titles[] = { "a", "b" }; | 381 const char* titles[] = { "a", "b" }; |
382 const char* urls[] = {kAboutBlankURL, kAboutBlankURL}; | 382 const char* urls[] = {kAboutBlankURL, kAboutBlankURL}; |
383 AddBookmarks(titles, urls, arraysize(titles)); | 383 AddBookmarks(titles, urls, arraysize(titles)); |
384 | 384 |
385 // Remove the node and make sure we don't get back any results. | 385 // Remove the node and make sure we don't get back any results. |
386 const char* expected[] = { "blah" }; | 386 const char* expected[] = { "blah" }; |
387 model_->SetTitle(model_->other_node()->GetChild(0), ASCIIToUTF16("blah")); | 387 model_->SetTitle(model_->other_node()->GetChild(0), ASCIIToUTF16("blah")); |
388 ExpectMatches("BlAh", expected, arraysize(expected)); | 388 ExpectMatches("BlAh", expected, arraysize(expected)); |
389 } | 389 } |
390 | 390 |
| 391 // Makes sure index is updated when a node's URL is changed. |
| 392 TEST_F(BookmarkIndexTest, ChangeURL) { |
| 393 const char* titles[] = { "a", "b" }; |
| 394 const char* urls[] = {"http://fizz", |
| 395 "http://fuzz"}; |
| 396 AddBookmarks(titles, urls, arraysize(titles)); |
| 397 |
| 398 const char* expected[] = { "a" }; |
| 399 model_->SetURL(model_->other_node()->GetChild(0), GURL("http://blah")); |
| 400 ExpectMatches("blah", expected, arraysize(expected)); |
| 401 } |
| 402 |
391 // Makes sure no more than max queries is returned. | 403 // Makes sure no more than max queries is returned. |
392 TEST_F(BookmarkIndexTest, HonorMax) { | 404 TEST_F(BookmarkIndexTest, HonorMax) { |
393 const char* titles[] = { "abcd", "abcde" }; | 405 const char* titles[] = { "abcd", "abcde" }; |
394 const char* urls[] = {kAboutBlankURL, kAboutBlankURL}; | 406 const char* urls[] = {kAboutBlankURL, kAboutBlankURL}; |
395 AddBookmarks(titles, urls, arraysize(titles)); | 407 AddBookmarks(titles, urls, arraysize(titles)); |
396 | 408 |
397 std::vector<BookmarkMatch> matches; | 409 std::vector<BookmarkMatch> matches; |
398 model_->GetBookmarksMatching(ASCIIToUTF16("ABc"), 1, &matches); | 410 model_->GetBookmarksMatching(ASCIIToUTF16("ABc"), 1, &matches); |
399 EXPECT_EQ(1U, matches.size()); | 411 EXPECT_EQ(1U, matches.size()); |
400 } | 412 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 // Select top two matches. | 468 // Select top two matches. |
457 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches); | 469 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches); |
458 | 470 |
459 ASSERT_EQ(2, static_cast<int>(matches.size())); | 471 ASSERT_EQ(2, static_cast<int>(matches.size())); |
460 EXPECT_EQ(data[0].url, matches[0].node->url()); | 472 EXPECT_EQ(data[0].url, matches[0].node->url()); |
461 EXPECT_EQ(data[3].url, matches[1].node->url()); | 473 EXPECT_EQ(data[3].url, matches[1].node->url()); |
462 } | 474 } |
463 | 475 |
464 } // namespace | 476 } // namespace |
465 } // namespace bookmarks | 477 } // namespace bookmarks |
OLD | NEW |