| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "content/browser/appcache/appcache_disk_cache.h" | 11 #include "content/browser/appcache/appcache_disk_cache.h" |
| 12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class AppCacheDiskCacheTest : public testing::Test { | 18 class AppCacheDiskCacheTest : public testing::Test { |
| 19 public: | 19 public: |
| 20 AppCacheDiskCacheTest() {} | 20 AppCacheDiskCacheTest() {} |
| 21 | 21 |
| 22 virtual void SetUp() OVERRIDE { | 22 virtual void SetUp() override { |
| 23 // Use the current thread for the DiskCache's cache_thread. | 23 // Use the current thread for the DiskCache's cache_thread. |
| 24 message_loop_.reset(new base::MessageLoopForIO()); | 24 message_loop_.reset(new base::MessageLoopForIO()); |
| 25 cache_thread_ = base::ThreadTaskRunnerHandle::Get(); | 25 cache_thread_ = base::ThreadTaskRunnerHandle::Get(); |
| 26 ASSERT_TRUE(directory_.CreateUniqueTempDir()); | 26 ASSERT_TRUE(directory_.CreateUniqueTempDir()); |
| 27 completion_callback_ = base::Bind( | 27 completion_callback_ = base::Bind( |
| 28 &AppCacheDiskCacheTest::OnComplete, | 28 &AppCacheDiskCacheTest::OnComplete, |
| 29 base::Unretained(this)); | 29 base::Unretained(this)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void TearDown() OVERRIDE { | 32 virtual void TearDown() override { |
| 33 base::RunLoop().RunUntilIdle(); | 33 base::RunLoop().RunUntilIdle(); |
| 34 message_loop_.reset(NULL); | 34 message_loop_.reset(NULL); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void FlushCacheTasks() { | 37 void FlushCacheTasks() { |
| 38 base::RunLoop().RunUntilIdle(); | 38 base::RunLoop().RunUntilIdle(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void OnComplete(int err) { | 41 void OnComplete(int err) { |
| 42 completion_results_.push_back(err); | 42 completion_results_.push_back(err); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 EXPECT_EQ( | 175 EXPECT_EQ( |
| 176 net::ERR_ABORTED, | 176 net::ERR_ABORTED, |
| 177 entry1->Read(0, 0, read_buf.get(), kDataLen, completion_callback_)); | 177 entry1->Read(0, 0, read_buf.get(), kDataLen, completion_callback_)); |
| 178 entry1->Close(); | 178 entry1->Close(); |
| 179 entry2->Close(); | 179 entry2->Close(); |
| 180 | 180 |
| 181 FlushCacheTasks(); | 181 FlushCacheTasks(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace content | 184 } // namespace content |
| OLD | NEW |