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

Side by Side Diff: base/files/file_util_proxy_unittest.cc

Issue 2103333006: Remove calls to deprecated MessageLoop methods in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « base/files/file_proxy_unittest.cc ('k') | base/files/important_file_writer_unittest.cc » ('j') | 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 "base/files/file_util_proxy.h" 5 #include "base/files/file_util_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/run_loop.h"
11 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace base { 15 namespace base {
15 16
16 class FileUtilProxyTest : public testing::Test { 17 class FileUtilProxyTest : public testing::Test {
17 public: 18 public:
18 FileUtilProxyTest() 19 FileUtilProxyTest()
19 : file_thread_("FileUtilProxyTestFileThread"), 20 : file_thread_("FileUtilProxyTestFileThread"),
20 error_(File::FILE_OK), 21 error_(File::FILE_OK),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Setup. 61 // Setup.
61 ASSERT_EQ(4, WriteFile(test_path(), "test", 4)); 62 ASSERT_EQ(4, WriteFile(test_path(), "test", 4));
62 File::Info expected_info; 63 File::Info expected_info;
63 GetFileInfo(test_path(), &expected_info); 64 GetFileInfo(test_path(), &expected_info);
64 65
65 // Run. 66 // Run.
66 FileUtilProxy::GetFileInfo( 67 FileUtilProxy::GetFileInfo(
67 file_task_runner(), 68 file_task_runner(),
68 test_path(), 69 test_path(),
69 Bind(&FileUtilProxyTest::DidGetFileInfo, weak_factory_.GetWeakPtr())); 70 Bind(&FileUtilProxyTest::DidGetFileInfo, weak_factory_.GetWeakPtr()));
70 MessageLoop::current()->Run(); 71 RunLoop().Run();
71 72
72 // Verify. 73 // Verify.
73 EXPECT_EQ(File::FILE_OK, error_); 74 EXPECT_EQ(File::FILE_OK, error_);
74 EXPECT_EQ(expected_info.size, file_info_.size); 75 EXPECT_EQ(expected_info.size, file_info_.size);
75 EXPECT_EQ(expected_info.is_directory, file_info_.is_directory); 76 EXPECT_EQ(expected_info.is_directory, file_info_.is_directory);
76 EXPECT_EQ(expected_info.is_symbolic_link, file_info_.is_symbolic_link); 77 EXPECT_EQ(expected_info.is_symbolic_link, file_info_.is_symbolic_link);
77 EXPECT_EQ(expected_info.last_modified, file_info_.last_modified); 78 EXPECT_EQ(expected_info.last_modified, file_info_.last_modified);
78 EXPECT_EQ(expected_info.last_accessed, file_info_.last_accessed); 79 EXPECT_EQ(expected_info.last_accessed, file_info_.last_accessed);
79 EXPECT_EQ(expected_info.creation_time, file_info_.creation_time); 80 EXPECT_EQ(expected_info.creation_time, file_info_.creation_time);
80 } 81 }
81 82
82 TEST_F(FileUtilProxyTest, GetFileInfo_Directory) { 83 TEST_F(FileUtilProxyTest, GetFileInfo_Directory) {
83 // Setup. 84 // Setup.
84 ASSERT_TRUE(base::CreateDirectory(test_path())); 85 ASSERT_TRUE(base::CreateDirectory(test_path()));
85 File::Info expected_info; 86 File::Info expected_info;
86 GetFileInfo(test_path(), &expected_info); 87 GetFileInfo(test_path(), &expected_info);
87 88
88 // Run. 89 // Run.
89 FileUtilProxy::GetFileInfo( 90 FileUtilProxy::GetFileInfo(
90 file_task_runner(), 91 file_task_runner(),
91 test_path(), 92 test_path(),
92 Bind(&FileUtilProxyTest::DidGetFileInfo, weak_factory_.GetWeakPtr())); 93 Bind(&FileUtilProxyTest::DidGetFileInfo, weak_factory_.GetWeakPtr()));
93 MessageLoop::current()->Run(); 94 RunLoop().Run();
94 95
95 // Verify. 96 // Verify.
96 EXPECT_EQ(File::FILE_OK, error_); 97 EXPECT_EQ(File::FILE_OK, error_);
97 EXPECT_EQ(expected_info.size, file_info_.size); 98 EXPECT_EQ(expected_info.size, file_info_.size);
98 EXPECT_EQ(expected_info.is_directory, file_info_.is_directory); 99 EXPECT_EQ(expected_info.is_directory, file_info_.is_directory);
99 EXPECT_EQ(expected_info.is_symbolic_link, file_info_.is_symbolic_link); 100 EXPECT_EQ(expected_info.is_symbolic_link, file_info_.is_symbolic_link);
100 EXPECT_EQ(expected_info.last_modified, file_info_.last_modified); 101 EXPECT_EQ(expected_info.last_modified, file_info_.last_modified);
101 EXPECT_EQ(expected_info.last_accessed, file_info_.last_accessed); 102 EXPECT_EQ(expected_info.last_accessed, file_info_.last_accessed);
102 EXPECT_EQ(expected_info.creation_time, file_info_.creation_time); 103 EXPECT_EQ(expected_info.creation_time, file_info_.creation_time);
103 } 104 }
104 105
105 TEST_F(FileUtilProxyTest, Touch) { 106 TEST_F(FileUtilProxyTest, Touch) {
106 ASSERT_EQ(4, WriteFile(test_path(), "test", 4)); 107 ASSERT_EQ(4, WriteFile(test_path(), "test", 4));
107 Time last_accessed_time = Time::Now() - TimeDelta::FromDays(12345); 108 Time last_accessed_time = Time::Now() - TimeDelta::FromDays(12345);
108 Time last_modified_time = Time::Now() - TimeDelta::FromHours(98765); 109 Time last_modified_time = Time::Now() - TimeDelta::FromHours(98765);
109 110
110 FileUtilProxy::Touch( 111 FileUtilProxy::Touch(
111 file_task_runner(), 112 file_task_runner(),
112 test_path(), 113 test_path(),
113 last_accessed_time, 114 last_accessed_time,
114 last_modified_time, 115 last_modified_time,
115 Bind(&FileUtilProxyTest::DidFinish, weak_factory_.GetWeakPtr())); 116 Bind(&FileUtilProxyTest::DidFinish, weak_factory_.GetWeakPtr()));
116 MessageLoop::current()->Run(); 117 RunLoop().Run();
117 EXPECT_EQ(File::FILE_OK, error_); 118 EXPECT_EQ(File::FILE_OK, error_);
118 119
119 File::Info info; 120 File::Info info;
120 GetFileInfo(test_path(), &info); 121 GetFileInfo(test_path(), &info);
121 122
122 // The returned values may only have the seconds precision, so we cast 123 // The returned values may only have the seconds precision, so we cast
123 // the double values to int here. 124 // the double values to int here.
124 EXPECT_EQ(static_cast<int>(last_modified_time.ToDoubleT()), 125 EXPECT_EQ(static_cast<int>(last_modified_time.ToDoubleT()),
125 static_cast<int>(info.last_modified.ToDoubleT())); 126 static_cast<int>(info.last_modified.ToDoubleT()));
126 EXPECT_EQ(static_cast<int>(last_accessed_time.ToDoubleT()), 127 EXPECT_EQ(static_cast<int>(last_accessed_time.ToDoubleT()),
127 static_cast<int>(info.last_accessed.ToDoubleT())); 128 static_cast<int>(info.last_accessed.ToDoubleT()));
128 } 129 }
129 130
130 } // namespace base 131 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_proxy_unittest.cc ('k') | base/files/important_file_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698