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

Side by Side Diff: remoting/host/config_file_watcher_unittest.cc

Issue 14314026: remoting: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "remoting/host/config_file_watcher.h" 5 #include "remoting/host/config_file_watcher.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 virtual ~ConfigFileWatcherTest(); 42 virtual ~ConfigFileWatcherTest();
43 43
44 // testing::Test overrides 44 // testing::Test overrides
45 virtual void SetUp() OVERRIDE; 45 virtual void SetUp() OVERRIDE;
46 virtual void TearDown() OVERRIDE; 46 virtual void TearDown() OVERRIDE;
47 47
48 // Stops the config file watcher. 48 // Stops the config file watcher.
49 void StopWatcher(); 49 void StopWatcher();
50 50
51 protected: 51 protected:
52 MessageLoop message_loop_; 52 base::MessageLoop message_loop_;
53 base::RunLoop run_loop_; 53 base::RunLoop run_loop_;
54 54
55 ConfigFileWatcherDelegate delegate_; 55 ConfigFileWatcherDelegate delegate_;
56 56
57 // Path to the configuration file used. 57 // Path to the configuration file used.
58 base::FilePath config_file_; 58 base::FilePath config_file_;
59 59
60 // The configuration file watcher that is being tested. 60 // The configuration file watcher that is being tested.
61 scoped_ptr<ConfigFileWatcher> watcher_; 61 scoped_ptr<ConfigFileWatcher> watcher_;
62 }; 62 };
63 63
64
65 ConfigFileWatcherTest::ConfigFileWatcherTest() 64 ConfigFileWatcherTest::ConfigFileWatcherTest()
66 : message_loop_(MessageLoop::TYPE_UI) { 65 : message_loop_(base::MessageLoop::TYPE_UI) {}
alexeypa (please no reviews) 2013/04/29 17:17:41 nit: Please move the closing bracket to the next l
xhwang 2013/04/30 00:02:36 Done.
67 }
68 66
69 ConfigFileWatcherTest::~ConfigFileWatcherTest() { 67 ConfigFileWatcherTest::~ConfigFileWatcherTest() {
70 } 68 }
71 69
72 void ConfigFileWatcherTest::StopWatcher() { 70 void ConfigFileWatcherTest::StopWatcher() {
73 watcher_.reset(); 71 watcher_.reset();
74 } 72 }
75 73
76 void ConfigFileWatcherTest::SetUp() { 74 void ConfigFileWatcherTest::SetUp() {
77 // Arrange to run |message_loop_| until no components depend on it. 75 // Arrange to run |message_loop_| until no components depend on it.
78 scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( 76 scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner(
79 message_loop_.message_loop_proxy(), run_loop_.QuitClosure()); 77 message_loop_.message_loop_proxy(), run_loop_.QuitClosure());
80 78
81 scoped_refptr<AutoThreadTaskRunner> io_task_runner = 79 scoped_refptr<AutoThreadTaskRunner> io_task_runner =
82 AutoThread::CreateWithType("IPC thread", task_runner, 80 AutoThread::CreateWithType(
83 MessageLoop::TYPE_IO); 81 "IPC thread", task_runner, base::MessageLoop::TYPE_IO);
84 82
85 // Create an instance of the config watcher. 83 // Create an instance of the config watcher.
86 watcher_.reset( 84 watcher_.reset(
87 new ConfigFileWatcher(task_runner, io_task_runner, &delegate_)); 85 new ConfigFileWatcher(task_runner, io_task_runner, &delegate_));
88 } 86 }
89 87
90 void ConfigFileWatcherTest::TearDown() { 88 void ConfigFileWatcherTest::TearDown() {
91 // Delete the test file. 89 // Delete the test file.
92 if (!config_file_.empty()) 90 if (!config_file_.empty())
93 file_util::Delete(config_file_, false); 91 file_util::Delete(config_file_, false);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 127
130 // Modify the watched file. 128 // Modify the watched file.
131 std::string data("test"); 129 std::string data("test");
132 EXPECT_NE(file_util::WriteFile(config_file_, data.c_str(), 130 EXPECT_NE(file_util::WriteFile(config_file_, data.c_str(),
133 static_cast<int>(data.size())), -1); 131 static_cast<int>(data.size())), -1);
134 132
135 run_loop_.Run(); 133 run_loop_.Run();
136 } 134 }
137 135
138 } // namespace remoting 136 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698