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

Side by Side Diff: chrome/browser/chromeos/drive/resource_metadata_unittest.cc

Issue 23571005: drive: Remove unused functions from ResourceMetadata. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/drive/resource_metadata.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/resource_metadata.h" 5 #include "chrome/browser/chromeos/drive/resource_metadata.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 error = FILE_ERROR_FAILED; 335 error = FILE_ERROR_FAILED;
336 entries.reset(); 336 entries.reset();
337 resource_metadata_->ReadDirectoryByPathOnUIThread( 337 resource_metadata_->ReadDirectoryByPathOnUIThread(
338 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), 338 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
339 google_apis::test_util::CreateCopyResultCallback(&error, &entries)); 339 google_apis::test_util::CreateCopyResultCallback(&error, &entries));
340 test_util::RunBlockingPoolTask(); 340 test_util::RunBlockingPoolTask();
341 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); 341 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error);
342 EXPECT_FALSE(entries.get()); 342 EXPECT_FALSE(entries.get());
343 } 343 }
344 344
345 TEST_F(ResourceMetadataTestOnUIThread, GetResourceEntryPairByPaths) {
346 // Confirm that existing two files are found.
347 scoped_ptr<EntryInfoPairResult> pair_result;
348 resource_metadata_->GetResourceEntryPairByPathsOnUIThread(
349 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
350 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file5"),
351 google_apis::test_util::CreateCopyResultCallback(&pair_result));
352 test_util::RunBlockingPoolTask();
353 // The first entry should be found.
354 EXPECT_EQ(FILE_ERROR_OK, pair_result->first.error);
355 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
356 pair_result->first.path);
357 ASSERT_TRUE(pair_result->first.entry.get());
358 EXPECT_EQ("file4", pair_result->first.entry->base_name());
359 // The second entry should be found.
360 EXPECT_EQ(FILE_ERROR_OK, pair_result->second.error);
361 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file5"),
362 pair_result->second.path);
363 ASSERT_TRUE(pair_result->second.entry.get());
364 EXPECT_EQ("file5", pair_result->second.entry->base_name());
365
366 // Confirm that the first non existent file is not found.
367 pair_result.reset();
368 resource_metadata_->GetResourceEntryPairByPathsOnUIThread(
369 base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
370 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file5"),
371 google_apis::test_util::CreateCopyResultCallback(&pair_result));
372 test_util::RunBlockingPoolTask();
373 // The first entry should not be found.
374 EXPECT_EQ(FILE_ERROR_NOT_FOUND, pair_result->first.error);
375 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
376 pair_result->first.path);
377 ASSERT_FALSE(pair_result->first.entry.get());
378 // The second entry should not be found, because the first one failed.
379 EXPECT_EQ(FILE_ERROR_FAILED, pair_result->second.error);
380 EXPECT_EQ(base::FilePath(), pair_result->second.path);
381 ASSERT_FALSE(pair_result->second.entry.get());
382
383 // Confirm that the second non existent file is not found.
384 pair_result.reset();
385 resource_metadata_->GetResourceEntryPairByPathsOnUIThread(
386 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
387 base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
388 google_apis::test_util::CreateCopyResultCallback(&pair_result));
389 test_util::RunBlockingPoolTask();
390 // The first entry should be found.
391 EXPECT_EQ(FILE_ERROR_OK, pair_result->first.error);
392 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
393 pair_result->first.path);
394 ASSERT_TRUE(pair_result->first.entry.get());
395 EXPECT_EQ("file4", pair_result->first.entry->base_name());
396 // The second entry should not be found.
397 EXPECT_EQ(FILE_ERROR_NOT_FOUND, pair_result->second.error);
398 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
399 pair_result->second.path);
400 ASSERT_FALSE(pair_result->second.entry.get());
401 }
402
403 TEST_F(ResourceMetadataTestOnUIThread, Reset) { 345 TEST_F(ResourceMetadataTestOnUIThread, Reset) {
404 // The grand root has "root" which is not empty. 346 // The grand root has "root" which is not empty.
405 scoped_ptr<ResourceEntryVector> entries; 347 scoped_ptr<ResourceEntryVector> entries;
406 entries = ReadDirectoryByPathSync( 348 entries = ReadDirectoryByPathSync(
407 base::FilePath::FromUTF8Unsafe("drive/root")); 349 base::FilePath::FromUTF8Unsafe("drive/root"));
408 ASSERT_TRUE(entries.get()); 350 ASSERT_TRUE(entries.get());
409 ASSERT_FALSE(entries->empty()); 351 ASSERT_FALSE(entries->empty());
410 352
411 // Reset. 353 // Reset.
412 FileError error = FILE_ERROR_FAILED; 354 FileError error = FILE_ERROR_FAILED;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 else 646 else
705 ++directory_count; 647 ++directory_count;
706 } 648 }
707 649
708 EXPECT_EQ(7, file_count); 650 EXPECT_EQ(7, file_count);
709 EXPECT_EQ(6, directory_count); 651 EXPECT_EQ(6, directory_count);
710 } 652 }
711 653
712 } // namespace internal 654 } // namespace internal
713 } // namespace drive 655 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/resource_metadata.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698