| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/timer.h" | 7 #include "base/timer.h" |
| 8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/renderer_host/file_system_accessor.h" | 9 #include "chrome/browser/renderer_host/file_system_accessor.h" |
| 10 #include "chrome/test/file_test_utils.h" | 10 #include "chrome/test/file_test_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 class FileSystemAccessorTest : public testing::Test { | 13 class FileSystemAccessorTest : public testing::Test { |
| 14 protected: | 14 protected: |
| 15 virtual void SetUp() { | 15 virtual void SetUp() { |
| 16 // Make sure the current thread has a message loop. | 16 // Make sure the current thread has a message loop. |
| 17 EXPECT_TRUE(MessageLoop::current() != NULL); | 17 EXPECT_TRUE(MessageLoop::current() != NULL); |
| 18 | 18 |
| 19 // Create FILE thread which is used to do file access. | 19 // Create FILE thread which is used to do file access. |
| 20 file_thread_.reset(new ChromeThread(ChromeThread::FILE)); | 20 file_thread_.reset(new ChromeThread(ChromeThread::FILE)); |
| 21 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::FILE) == NULL); | |
| 22 | 21 |
| 23 // Start FILE thread and verify FILE message loop exists. | 22 // Start FILE thread and verify FILE message loop exists. |
| 24 file_thread_->Start(); | 23 file_thread_->Start(); |
| 25 EXPECT_TRUE(file_thread_->message_loop() != NULL); | 24 EXPECT_TRUE(file_thread_->message_loop() != NULL); |
| 26 } | 25 } |
| 27 | 26 |
| 28 virtual void TearDown() { | 27 virtual void TearDown() { |
| 29 file_thread_->Stop(); | 28 file_thread_->Stop(); |
| 30 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::FILE) == NULL); | |
| 31 } | 29 } |
| 32 | 30 |
| 33 void TestGetFileSize(const FilePath& path, | 31 void TestGetFileSize(const FilePath& path, |
| 34 void* param, | 32 void* param, |
| 35 int64 expected_result, | 33 int64 expected_result, |
| 36 void* expected_param) { | 34 void* expected_param) { |
| 37 // Initialize the actual result not equal to the expected result. | 35 // Initialize the actual result not equal to the expected result. |
| 38 result_ = expected_result + 1; | 36 result_ = expected_result + 1; |
| 39 param_ = NULL; | 37 param_ = NULL; |
| 40 | 38 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 106 } |
| 109 | 107 |
| 110 TEST_F(FileSystemAccessorTest, GetFileSizeNotFound) { | 108 TEST_F(FileSystemAccessorTest, GetFileSizeNotFound) { |
| 111 FilePath path; | 109 FilePath path; |
| 112 EXPECT_TRUE(file_util::CreateNewTempDirectory( | 110 EXPECT_TRUE(file_util::CreateNewTempDirectory( |
| 113 FILE_PATH_LITERAL("chrome_test_"), &path)); | 111 FILE_PATH_LITERAL("chrome_test_"), &path)); |
| 114 FileAutoDeleter deleter(path); | 112 FileAutoDeleter deleter(path); |
| 115 | 113 |
| 116 TestGetFileSize(path.Append(FILE_PATH_LITERAL("foo.txt")), NULL, -1, NULL); | 114 TestGetFileSize(path.Append(FILE_PATH_LITERAL("foo.txt")), NULL, -1, NULL); |
| 117 } | 115 } |
| OLD | NEW |