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/file_util.h" | 7 #include "base/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" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" | 13 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" |
14 #include "chrome/browser/chromeos/drive/file_cache.h" | 14 #include "chrome/browser/chromeos/drive/file_cache.h" |
15 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
16 #include "chrome/browser/chromeos/drive/test_util.h" | 16 #include "chrome/browser/chromeos/drive/test_util.h" |
| 17 #include "chrome/browser/drive/drive_api_util.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 namespace drive { | 21 namespace drive { |
21 namespace internal { | 22 namespace internal { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 const int kDefaultAtMostNumMatches = 10; | 26 const int kDefaultAtMostNumMatches = 10; |
26 | 27 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(GetFileEntry( | 111 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(GetFileEntry( |
111 "File 2.txt", "file2", 7, root_local_id), &local_id)); | 112 "File 2.txt", "file2", 7, root_local_id), &local_id)); |
112 EXPECT_EQ(FILE_ERROR_OK, cache_->Store( | 113 EXPECT_EQ(FILE_ERROR_OK, cache_->Store( |
113 local_id, temp_file_md5, temp_file, FileCache::FILE_OPERATION_COPY)); | 114 local_id, temp_file_md5, temp_file, FileCache::FILE_OPERATION_COPY)); |
114 | 115 |
115 // drive/root/Document 1 excludeDir-test | 116 // drive/root/Document 1 excludeDir-test |
116 entry = GetFileEntry( | 117 entry = GetFileEntry( |
117 "Document 1 excludeDir-test", "doc1", 8, root_local_id); | 118 "Document 1 excludeDir-test", "doc1", 8, root_local_id); |
118 entry.mutable_file_specific_info()->set_is_hosted_document(true); | 119 entry.mutable_file_specific_info()->set_is_hosted_document(true); |
119 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( |
| 122 drive::util::kGoogleDocumentMimeType); |
120 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(entry, &local_id)); | 123 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(entry, &local_id)); |
121 | 124 |
122 } | 125 } |
123 | 126 |
124 ResourceEntry GetFileEntry(const std::string& name, | 127 ResourceEntry GetFileEntry(const std::string& name, |
125 const std::string& resource_id, | 128 const std::string& resource_id, |
126 int64 last_accessed, | 129 int64 last_accessed, |
127 const std::string& parent_local_id) { | 130 const std::string& parent_local_id) { |
128 ResourceEntry entry; | 131 ResourceEntry entry; |
129 entry.set_title(name); | 132 entry.set_title(name); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 519 } |
517 | 520 |
518 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) { | 521 TEST(SearchMetadataSimpleTest, FindAndHighlight_MoreMetaChars) { |
519 std::string highlighted_text; | 522 std::string highlighted_text; |
520 EXPECT_TRUE(FindAndHighlightWrapper("a&b&c&d", "b&c", &highlighted_text)); | 523 EXPECT_TRUE(FindAndHighlightWrapper("a&b&c&d", "b&c", &highlighted_text)); |
521 EXPECT_EQ("a&<b>b&c</b>&d", highlighted_text); | 524 EXPECT_EQ("a&<b>b&c</b>&d", highlighted_text); |
522 } | 525 } |
523 | 526 |
524 } // namespace internal | 527 } // namespace internal |
525 } // namespace drive | 528 } // namespace drive |
OLD | NEW |