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

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_unittest.cc

Issue 2580713004: mediaview: Implement ArcDocumentsProviderBackendDelegate. (Closed)
Patch Set: Removed unused #include. Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <string.h> 5 #include <string.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h" 14 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
15 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" 15 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
16 #include "components/arc/arc_bridge_service.h" 16 #include "components/arc/arc_bridge_service.h"
17 #include "components/arc/arc_service_manager.h" 17 #include "components/arc/arc_service_manager.h"
18 #include "components/arc/test/fake_file_system_instance.h" 18 #include "components/arc/test/fake_file_system_instance.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "storage/common/fileapi/directory_entry.h" 20 #include "storage/common/fileapi/directory_entry.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "url/gurl.h"
22 23
23 using storage::DirectoryEntry; 24 using storage::DirectoryEntry;
24 using EntryList = storage::AsyncFileUtil::EntryList; 25 using EntryList = storage::AsyncFileUtil::EntryList;
25 26
26 namespace arc { 27 namespace arc {
27 28
28 namespace { 29 namespace {
29 30
30 struct DocumentSpec { 31 struct DocumentSpec {
31 const char* document_id; 32 const char* document_id;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 EXPECT_FALSE(file_list[2].is_directory); 303 EXPECT_FALSE(file_list[2].is_directory);
303 EXPECT_EQ(FILE_PATH_LITERAL("dup.mp4"), file_list[3].name); 304 EXPECT_EQ(FILE_PATH_LITERAL("dup.mp4"), file_list[3].name);
304 EXPECT_FALSE(file_list[3].is_directory); 305 EXPECT_FALSE(file_list[3].is_directory);
305 EXPECT_FALSE(has_more); 306 EXPECT_FALSE(has_more);
306 run_loop->Quit(); 307 run_loop->Quit();
307 }, 308 },
308 &run_loop)); 309 &run_loop));
309 run_loop.Run(); 310 run_loop.Run();
310 } 311 }
311 312
313 TEST_F(ArcDocumentsProviderRootTest, ResolveToContentUrl) {
314 base::RunLoop run_loop;
315 root_->ResolveToContentUrl(
316 base::FilePath(FILE_PATH_LITERAL("dir/photo.jpg")),
317 base::Bind(
318 [](base::RunLoop* run_loop, const GURL& url) {
319 EXPECT_EQ(GURL("content://org.chromium.test/document/photo-id"),
320 url);
321 run_loop->Quit();
322 },
323 &run_loop));
324 run_loop.Run();
325 }
326
327 TEST_F(ArcDocumentsProviderRootTest, ResolveToContentUrlRoot) {
328 base::RunLoop run_loop;
329 root_->ResolveToContentUrl(
330 base::FilePath(FILE_PATH_LITERAL("")),
331 base::Bind(
332 [](base::RunLoop* run_loop, const GURL& url) {
333 EXPECT_EQ(GURL("content://org.chromium.test/document/root-id"),
334 url);
335 run_loop->Quit();
336 },
337 &run_loop));
338 run_loop.Run();
339 }
340
341 TEST_F(ArcDocumentsProviderRootTest, ResolveToContentUrlNoSuchFile) {
342 base::RunLoop run_loop;
343 root_->ResolveToContentUrl(base::FilePath(FILE_PATH_LITERAL("missing")),
344 base::Bind(
345 [](base::RunLoop* run_loop, const GURL& url) {
346 EXPECT_EQ(GURL(), url);
347 run_loop->Quit();
348 },
349 &run_loop));
350 run_loop.Run();
351 }
352
353 TEST_F(ArcDocumentsProviderRootTest, ResolveToContentUrlDups) {
354 base::RunLoop run_loop;
355 // "dup 2.mp4" should map to the 3rd instance of "dup.mp4" regardless of the
356 // order returned from FileSystemInstance.
357 root_->ResolveToContentUrl(
358 base::FilePath(FILE_PATH_LITERAL("dups/dup (2).mp4")),
359 base::Bind(
360 [](base::RunLoop* run_loop, const GURL& url) {
361 EXPECT_EQ(GURL("content://org.chromium.test/document/dup3-id"),
362 url);
363 run_loop->Quit();
364 },
365 &run_loop));
366 run_loop.Run();
367 }
368
312 } // namespace arc 369 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698