| 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/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/i18n/string_search.h" | 9 #include "base/i18n/string_search.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 local_id, temp_file_md5, temp_file, FileCache::FILE_OPERATION_COPY)); | 114 local_id, temp_file_md5, temp_file, FileCache::FILE_OPERATION_COPY)); |
| 115 | 115 |
| 116 // drive/root/Document 1 excludeDir-test | 116 // drive/root/Document 1 excludeDir-test |
| 117 entry = GetFileEntry( | 117 entry = GetFileEntry( |
| 118 "Document 1 excludeDir-test", "doc1", 8, root_local_id); | 118 "Document 1 excludeDir-test", "doc1", 8, root_local_id); |
| 119 entry.mutable_file_specific_info()->set_is_hosted_document(true); | 119 entry.mutable_file_specific_info()->set_is_hosted_document(true); |
| 120 entry.mutable_file_specific_info()->set_document_extension(".gdoc"); | 120 entry.mutable_file_specific_info()->set_document_extension(".gdoc"); |
| 121 entry.mutable_file_specific_info()->set_content_mime_type( | 121 entry.mutable_file_specific_info()->set_content_mime_type( |
| 122 drive::util::kGoogleDocumentMimeType); | 122 drive::util::kGoogleDocumentMimeType); |
| 123 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(entry, &local_id)); | 123 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(entry, &local_id)); |
| 124 | |
| 125 } | 124 } |
| 126 | 125 |
| 127 ResourceEntry GetFileEntry(const std::string& name, | 126 ResourceEntry GetFileEntry(const std::string& name, |
| 128 const std::string& resource_id, | 127 const std::string& resource_id, |
| 129 int64 last_accessed, | 128 int64 last_accessed, |
| 130 const std::string& parent_local_id) { | 129 const std::string& parent_local_id) { |
| 131 ResourceEntry entry; | 130 ResourceEntry entry; |
| 132 entry.set_title(name); | 131 entry.set_title(name); |
| 133 entry.set_resource_id(resource_id); | 132 entry.set_resource_id(resource_id); |
| 134 entry.set_parent_local_id(parent_local_id); | 133 entry.set_parent_local_id(parent_local_id); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 EXPECT_EQ(FILE_ERROR_OK, error); | 374 EXPECT_EQ(FILE_ERROR_OK, error); |
| 376 ASSERT_TRUE(result); | 375 ASSERT_TRUE(result); |
| 377 ASSERT_EQ(1U, result->size()); | 376 ASSERT_EQ(1U, result->size()); |
| 378 | 377 |
| 379 EXPECT_EQ("drive/root/Document 1 excludeDir-test.gdoc", | 378 EXPECT_EQ("drive/root/Document 1 excludeDir-test.gdoc", |
| 380 result->at(0).path.AsUTF8Unsafe()); | 379 result->at(0).path.AsUTF8Unsafe()); |
| 381 } | 380 } |
| 382 | 381 |
| 383 // "drive", "drive/root", "drive/other" should be excluded. | 382 // "drive", "drive/root", "drive/other" should be excluded. |
| 384 TEST_F(SearchMetadataTest, SearchMetadata_ExcludeSpecialDirectories) { | 383 TEST_F(SearchMetadataTest, SearchMetadata_ExcludeSpecialDirectories) { |
| 385 const char* kQueries[] = { "drive", "root", "other" }; | 384 const char* const kQueries[] = { "drive", "root", "other" }; |
| 386 for (size_t i = 0; i < arraysize(kQueries); ++i) { | 385 for (size_t i = 0; i < arraysize(kQueries); ++i) { |
| 387 FileError error = FILE_ERROR_FAILED; | 386 FileError error = FILE_ERROR_FAILED; |
| 388 scoped_ptr<MetadataSearchResultVector> result; | 387 scoped_ptr<MetadataSearchResultVector> result; |
| 389 | 388 |
| 390 const std::string query = kQueries[i]; | 389 const std::string query = kQueries[i]; |
| 391 SearchMetadata(base::MessageLoopProxy::current(), | 390 SearchMetadata(base::MessageLoopProxy::current(), |
| 392 resource_metadata_.get(), | 391 resource_metadata_.get(), |
| 393 query, | 392 query, |
| 394 SEARCH_METADATA_ALL, | 393 SEARCH_METADATA_ALL, |
| 395 kDefaultAtMostNumMatches, | 394 kDefaultAtMostNumMatches, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } | 518 } |
| 520 | 519 |
| 521 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) { | 520 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) { |
| 522 std::string highlighted_text; | 521 std::string highlighted_text; |
| 523 EXPECT_TRUE(FindAndHighlightWrapper("a&b&c&d", "b&c", &highlighted_text)); | 522 EXPECT_TRUE(FindAndHighlightWrapper("a&b&c&d", "b&c", &highlighted_text)); |
| 524 EXPECT_EQ("a&<b>b&c</b>&d", highlighted_text); | 523 EXPECT_EQ("a&<b>b&c</b>&d", highlighted_text); |
| 525 } | 524 } |
| 526 | 525 |
| 527 } // namespace internal | 526 } // namespace internal |
| 528 } // namespace drive | 527 } // namespace drive |
| OLD | NEW |