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

Side by Side Diff: chrome/common/important_file_writer_unittest.cc

Issue 8873032: Removing MessageLoop::QuitTask() from chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert 3 more problematic files Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/important_file_writer.h" 5 #include "chrome/common/important_file_writer.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 TEST_F(ImportantFileWriterTest, ScheduleWrite) { 70 TEST_F(ImportantFileWriterTest, ScheduleWrite) {
71 ImportantFileWriter writer(file_, 71 ImportantFileWriter writer(file_,
72 base::MessageLoopProxy::current()); 72 base::MessageLoopProxy::current());
73 writer.set_commit_interval(base::TimeDelta::FromMilliseconds(25)); 73 writer.set_commit_interval(base::TimeDelta::FromMilliseconds(25));
74 EXPECT_FALSE(writer.HasPendingWrite()); 74 EXPECT_FALSE(writer.HasPendingWrite());
75 DataSerializer serializer("foo"); 75 DataSerializer serializer("foo");
76 writer.ScheduleWrite(&serializer); 76 writer.ScheduleWrite(&serializer);
77 EXPECT_TRUE(writer.HasPendingWrite()); 77 EXPECT_TRUE(writer.HasPendingWrite());
78 MessageLoop::current()->PostDelayedTask(FROM_HERE, 78 MessageLoop::current()->PostDelayedTask(FROM_HERE,
79 new MessageLoop::QuitTask(), 100); 79 MessageLoop::QuitClosure(), 100);
80 MessageLoop::current()->Run(); 80 MessageLoop::current()->Run();
81 EXPECT_FALSE(writer.HasPendingWrite()); 81 EXPECT_FALSE(writer.HasPendingWrite());
82 ASSERT_TRUE(file_util::PathExists(writer.path())); 82 ASSERT_TRUE(file_util::PathExists(writer.path()));
83 EXPECT_EQ("foo", GetFileContent(writer.path())); 83 EXPECT_EQ("foo", GetFileContent(writer.path()));
84 } 84 }
85 85
86 TEST_F(ImportantFileWriterTest, DoScheduledWrite) { 86 TEST_F(ImportantFileWriterTest, DoScheduledWrite) {
87 ImportantFileWriter writer(file_, 87 ImportantFileWriter writer(file_,
88 base::MessageLoopProxy::current()); 88 base::MessageLoopProxy::current());
89 EXPECT_FALSE(writer.HasPendingWrite()); 89 EXPECT_FALSE(writer.HasPendingWrite());
90 DataSerializer serializer("foo"); 90 DataSerializer serializer("foo");
91 writer.ScheduleWrite(&serializer); 91 writer.ScheduleWrite(&serializer);
92 EXPECT_TRUE(writer.HasPendingWrite()); 92 EXPECT_TRUE(writer.HasPendingWrite());
93 writer.DoScheduledWrite(); 93 writer.DoScheduledWrite();
94 MessageLoop::current()->PostDelayedTask(FROM_HERE, 94 MessageLoop::current()->PostDelayedTask(FROM_HERE,
95 new MessageLoop::QuitTask(), 100); 95 MessageLoop::QuitClosure(), 100);
96 MessageLoop::current()->Run(); 96 MessageLoop::current()->Run();
97 EXPECT_FALSE(writer.HasPendingWrite()); 97 EXPECT_FALSE(writer.HasPendingWrite());
98 ASSERT_TRUE(file_util::PathExists(writer.path())); 98 ASSERT_TRUE(file_util::PathExists(writer.path()));
99 EXPECT_EQ("foo", GetFileContent(writer.path())); 99 EXPECT_EQ("foo", GetFileContent(writer.path()));
100 } 100 }
101 101
102 TEST_F(ImportantFileWriterTest, BatchingWrites) { 102 TEST_F(ImportantFileWriterTest, BatchingWrites) {
103 ImportantFileWriter writer(file_, 103 ImportantFileWriter writer(file_,
104 base::MessageLoopProxy::current()); 104 base::MessageLoopProxy::current());
105 writer.set_commit_interval(base::TimeDelta::FromMilliseconds(25)); 105 writer.set_commit_interval(base::TimeDelta::FromMilliseconds(25));
106 DataSerializer foo("foo"), bar("bar"), baz("baz"); 106 DataSerializer foo("foo"), bar("bar"), baz("baz");
107 writer.ScheduleWrite(&foo); 107 writer.ScheduleWrite(&foo);
108 writer.ScheduleWrite(&bar); 108 writer.ScheduleWrite(&bar);
109 writer.ScheduleWrite(&baz); 109 writer.ScheduleWrite(&baz);
110 MessageLoop::current()->PostDelayedTask(FROM_HERE, 110 MessageLoop::current()->PostDelayedTask(FROM_HERE,
111 new MessageLoop::QuitTask(), 100); 111 MessageLoop::QuitClosure(), 100);
112 MessageLoop::current()->Run(); 112 MessageLoop::current()->Run();
113 ASSERT_TRUE(file_util::PathExists(writer.path())); 113 ASSERT_TRUE(file_util::PathExists(writer.path()));
114 EXPECT_EQ("baz", GetFileContent(writer.path())); 114 EXPECT_EQ("baz", GetFileContent(writer.path()));
115 } 115 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service_unittest.cc ('k') | chrome/common/service_process_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698