OLD | NEW |
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/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 &error, &result)); | 318 &error, &result)); |
319 | 319 |
320 google_apis::test_util::RunBlockingPoolTask(); | 320 google_apis::test_util::RunBlockingPoolTask(); |
321 EXPECT_EQ(DRIVE_FILE_OK, error); | 321 EXPECT_EQ(DRIVE_FILE_OK, error); |
322 ASSERT_EQ(1U, result->size()); | 322 ASSERT_EQ(1U, result->size()); |
323 | 323 |
324 EXPECT_EQ("drive/root/Document 1 excludeDir-test.gdoc", | 324 EXPECT_EQ("drive/root/Document 1 excludeDir-test.gdoc", |
325 result->at(0).path.AsUTF8Unsafe()); | 325 result->at(0).path.AsUTF8Unsafe()); |
326 } | 326 } |
327 | 327 |
| 328 // "drive", "drive/root", "drive/other" should be excluded. |
| 329 TEST_F(SearchMetadataTest, SearchMetadata_ExcludeSpecialDirectories) { |
| 330 const char* kQueries[] = { "drive", "root", "other" }; |
| 331 for (size_t i = 0; i < arraysize(kQueries); ++i) { |
| 332 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 333 scoped_ptr<MetadataSearchResultVector> result; |
| 334 |
| 335 const std::string query = kQueries[i]; |
| 336 SearchMetadata(resource_metadata_.get(), |
| 337 query, |
| 338 SEARCH_METADATA_ALL, |
| 339 kDefaultAtMostNumMatches, |
| 340 google_apis::test_util::CreateCopyResultCallback( |
| 341 &error, &result)); |
| 342 |
| 343 google_apis::test_util::RunBlockingPoolTask(); |
| 344 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 345 ASSERT_TRUE(result->empty()) << ": " << query << " should not match"; |
| 346 } |
| 347 } |
| 348 |
328 TEST(SearchMetadataSimpleTest, FindAndHighlight_ZeroMatches) { | 349 TEST(SearchMetadataSimpleTest, FindAndHighlight_ZeroMatches) { |
329 std::string highlighted_text; | 350 std::string highlighted_text; |
330 EXPECT_FALSE(FindAndHighlight("text", "query", &highlighted_text)); | 351 EXPECT_FALSE(FindAndHighlight("text", "query", &highlighted_text)); |
331 } | 352 } |
332 | 353 |
333 TEST(SearchMetadataSimpleTest, FindAndHighlight_EmptyQuery) { | 354 TEST(SearchMetadataSimpleTest, FindAndHighlight_EmptyQuery) { |
334 std::string highlighted_text; | 355 std::string highlighted_text; |
335 EXPECT_TRUE(FindAndHighlight("text", "", &highlighted_text)); | 356 EXPECT_TRUE(FindAndHighlight("text", "", &highlighted_text)); |
336 EXPECT_EQ("", highlighted_text); | 357 EXPECT_EQ("", highlighted_text); |
337 } | 358 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 EXPECT_EQ("<<b>hello</b>>", highlighted_text); | 410 EXPECT_EQ("<<b>hello</b>>", highlighted_text); |
390 } | 411 } |
391 | 412 |
392 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) { | 413 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) { |
393 std::string highlighted_text; | 414 std::string highlighted_text; |
394 EXPECT_TRUE(FindAndHighlight("a&b&c&d", "b&c", &highlighted_text)); | 415 EXPECT_TRUE(FindAndHighlight("a&b&c&d", "b&c", &highlighted_text)); |
395 EXPECT_EQ("a&<b>b&c</b>&d", highlighted_text); | 416 EXPECT_EQ("a&<b>b&c</b>&d", highlighted_text); |
396 } | 417 } |
397 | 418 |
398 } // namespace drive | 419 } // namespace drive |
OLD | NEW |