OLD | NEW |
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/drive_cache.h" | 5 #include "chrome/browser/chromeos/drive/drive_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 current = enumerator.Next()) { | 616 current = enumerator.Next()) { |
617 ++num_files_found; | 617 ++num_files_found; |
618 EXPECT_EQ(util::EscapeCacheFileName(resource_id) + | 618 EXPECT_EQ(util::EscapeCacheFileName(resource_id) + |
619 base::FilePath::kExtensionSeparator + | 619 base::FilePath::kExtensionSeparator + |
620 util::EscapeCacheFileName(md5), | 620 util::EscapeCacheFileName(md5), |
621 current.BaseName().value()); | 621 current.BaseName().value()); |
622 } | 622 } |
623 return num_files_found; | 623 return num_files_found; |
624 } | 624 } |
625 | 625 |
626 MessageLoopForUI message_loop_; | 626 base::MessageLoopForUI message_loop_; |
627 // The order of the test threads is important, do not change the order. | 627 // The order of the test threads is important, do not change the order. |
628 // See also content/browser/browser_thread_imple.cc. | 628 // See also content/browser/browser_thread_imple.cc. |
629 content::TestBrowserThread ui_thread_; | 629 content::TestBrowserThread ui_thread_; |
630 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 630 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
631 scoped_ptr<TestingProfile> profile_; | 631 scoped_ptr<TestingProfile> profile_; |
632 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_; | 632 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_; |
633 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; | 633 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; |
634 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; | 634 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; |
635 | 635 |
636 FileError expected_error_; | 636 FileError expected_error_; |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 FILE_ERROR_NO_SPACE, | 1319 FILE_ERROR_NO_SPACE, |
1320 test_util::TEST_CACHE_STATE_NONE, | 1320 test_util::TEST_CACHE_STATE_NONE, |
1321 DriveCache::CACHE_TYPE_TMP); | 1321 DriveCache::CACHE_TYPE_TMP); |
1322 | 1322 |
1323 // Verify that there's no files added. | 1323 // Verify that there's no files added. |
1324 EXPECT_EQ(0U, CountCacheFiles(resource_id, md5)); | 1324 EXPECT_EQ(0U, CountCacheFiles(resource_id, md5)); |
1325 } | 1325 } |
1326 | 1326 |
1327 // Don't use TEST_F, as we don't want SetUp() and TearDown() for this test. | 1327 // Don't use TEST_F, as we don't want SetUp() and TearDown() for this test. |
1328 TEST(DriveCacheExtraTest, InitializationFailure) { | 1328 TEST(DriveCacheExtraTest, InitializationFailure) { |
1329 MessageLoopForUI message_loop; | 1329 base::MessageLoopForUI message_loop; |
1330 content::TestBrowserThread ui_thread(content::BrowserThread::UI, | 1330 content::TestBrowserThread ui_thread(content::BrowserThread::UI, |
1331 &message_loop); | 1331 &message_loop); |
1332 | 1332 |
1333 scoped_refptr<base::SequencedWorkerPool> pool = | 1333 scoped_refptr<base::SequencedWorkerPool> pool = |
1334 content::BrowserThread::GetBlockingPool(); | 1334 content::BrowserThread::GetBlockingPool(); |
1335 | 1335 |
1336 // Set the cache root to a non existent path, so the initialization fails. | 1336 // Set the cache root to a non existent path, so the initialization fails. |
1337 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache(new DriveCache( | 1337 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache(new DriveCache( |
1338 base::FilePath::FromUTF8Unsafe("/somewhere/nonexistent/blah/blah"), | 1338 base::FilePath::FromUTF8Unsafe("/somewhere/nonexistent/blah/blah"), |
1339 pool->GetSequencedTaskRunner(pool->GetSequenceToken()), | 1339 pool->GetSequencedTaskRunner(pool->GetSequenceToken()), |
1340 NULL /* free_disk_space_getter */)); | 1340 NULL /* free_disk_space_getter */)); |
1341 | 1341 |
1342 bool success = true; | 1342 bool success = true; |
1343 cache->RequestInitialize( | 1343 cache->RequestInitialize( |
1344 google_apis::test_util::CreateCopyResultCallback(&success)); | 1344 google_apis::test_util::CreateCopyResultCallback(&success)); |
1345 google_apis::test_util::RunBlockingPoolTask(); | 1345 google_apis::test_util::RunBlockingPoolTask(); |
1346 EXPECT_FALSE(success); | 1346 EXPECT_FALSE(success); |
1347 } | 1347 } |
1348 | 1348 |
1349 } // namespace drive | 1349 } // namespace drive |
OLD | NEW |