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

Side by Side Diff: mojo/common/handle_watcher_unittest.cc

Issue 218583009: Adds a way to associate key/value pairs with the environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make mojo_service_manager depend on mojo_common_lib Created 6 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
« no previous file with comments | « mojo/common/handle_watcher.cc ('k') | mojo/environment/environment.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "mojo/common/handle_watcher.h" 5 #include "mojo/common/handle_watcher.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/simple_test_tick_clock.h" 12 #include "base/test/simple_test_tick_clock.h"
13 #include "mojo/common/time_helper.h" 13 #include "mojo/common/time_helper.h"
14 #include "mojo/public/cpp/environment/environment.h"
14 #include "mojo/public/cpp/system/core.h" 15 #include "mojo/public/cpp/system/core.h"
15 #include "mojo/public/tests/test_utils.h" 16 #include "mojo/public/tests/test_utils.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace mojo { 19 namespace mojo {
19 namespace common { 20 namespace common {
20 namespace test { 21 namespace test {
21 22
22 void RunUntilIdle() { 23 void RunUntilIdle() {
23 base::RunLoop run_loop; 24 base::RunLoop run_loop;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); 94 DISALLOW_COPY_AND_ASSIGN(CallbackHelper);
94 }; 95 };
95 96
96 class HandleWatcherTest : public testing::Test { 97 class HandleWatcherTest : public testing::Test {
97 public: 98 public:
98 HandleWatcherTest() {} 99 HandleWatcherTest() {}
99 virtual ~HandleWatcherTest() { 100 virtual ~HandleWatcherTest() {
100 test::SetTickClockForTest(NULL); 101 test::SetTickClockForTest(NULL);
101 } 102 }
102 103
104 virtual void SetUp() OVERRIDE {
105 environment_.reset(new Environment);
106 }
107
108 virtual void TearDown() OVERRIDE {
109 environment_.reset();
110 }
111
103 protected: 112 protected:
104 void InstallTickClock() { 113 void InstallTickClock() {
105 test::SetTickClockForTest(&tick_clock_); 114 test::SetTickClockForTest(&tick_clock_);
106 } 115 }
107 116
108 base::SimpleTestTickClock tick_clock_; 117 base::SimpleTestTickClock tick_clock_;
109 118
110 private: 119 private:
111 base::MessageLoop message_loop_; 120 base::MessageLoop message_loop_;
121 scoped_ptr<Environment> environment_;
112 122
113 DISALLOW_COPY_AND_ASSIGN(HandleWatcherTest); 123 DISALLOW_COPY_AND_ASSIGN(HandleWatcherTest);
114 }; 124 };
115 125
116 // Trivial test case with a single handle to watch. 126 // Trivial test case with a single handle to watch.
117 TEST_F(HandleWatcherTest, SingleHandler) { 127 TEST_F(HandleWatcherTest, SingleHandler) {
118 MessagePipe test_pipe; 128 MessagePipe test_pipe;
119 ASSERT_TRUE(test_pipe.handle0.is_valid()); 129 ASSERT_TRUE(test_pipe.handle0.is_valid());
120 CallbackHelper callback_helper; 130 CallbackHelper callback_helper;
121 HandleWatcher watcher; 131 HandleWatcher watcher;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 callback_helper.GetCallback())); 311 callback_helper.GetCallback()));
302 EXPECT_TRUE(mojo::test::WriteTextMessage(test_pipe.handle0.get(), 312 EXPECT_TRUE(mojo::test::WriteTextMessage(test_pipe.handle0.get(),
303 std::string())); 313 std::string()));
304 callback_helper.RunUntilGotCallback(); 314 callback_helper.RunUntilGotCallback();
305 EXPECT_TRUE(callback_helper.got_callback()); 315 EXPECT_TRUE(callback_helper.got_callback());
306 } 316 }
307 317
308 } // namespace test 318 } // namespace test
309 } // namespace common 319 } // namespace common
310 } // namespace mojo 320 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/handle_watcher.cc ('k') | mojo/environment/environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698