OLD | NEW |
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 <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 base::RunLoop run_loop; | 143 base::RunLoop run_loop; |
144 ASSERT_TRUE(test_case_done_callback_.is_null()); | 144 ASSERT_TRUE(test_case_done_callback_.is_null()); |
145 test_case_done_callback_ = run_loop.QuitClosure(); | 145 test_case_done_callback_ = run_loop.QuitClosure(); |
146 | 146 |
147 const std::string& test_str = test_cases[i].input; | 147 const std::string& test_str = test_cases[i].input; |
148 // Let's make inputs not NULL terminated, unless other is specified in | 148 // Let's make inputs not NULL terminated, unless other is specified in |
149 // the test case. | 149 // the test case. |
150 ssize_t test_size = test_str.length() * sizeof(*test_str.c_str()); | 150 ssize_t test_size = test_str.length() * sizeof(*test_str.c_str()); |
151 if (test_cases[i].should_send_terminating_null) | 151 if (test_cases[i].should_send_terminating_null) |
152 test_size += sizeof(*test_str.c_str()); | 152 test_size += sizeof(*test_str.c_str()); |
153 EXPECT_EQ(test_size, | 153 EXPECT_TRUE(base::WriteFileDescriptor(pt_pipe[1], test_str.c_str(), |
154 base::WriteFileDescriptor(pt_pipe[1], test_str.c_str(), | 154 test_size)); |
155 test_size)); | |
156 | 155 |
157 run_loop.Run(); | 156 run_loop.Run(); |
158 EXPECT_TRUE(expectations_.IsDone()); | 157 EXPECT_TRUE(expectations_.IsDone()); |
159 if (failed_) | 158 if (failed_) |
160 break; | 159 break; |
161 } | 160 } |
162 | 161 |
163 // Send stop signal. It is not important which string we send. | 162 // Send stop signal. It is not important which string we send. |
164 EXPECT_EQ(1, base::WriteFileDescriptor(stop_pipe[1], "q", 1)); | 163 EXPECT_TRUE(base::WriteFileDescriptor(stop_pipe[1], "q", 1)); |
165 | 164 |
166 EXPECT_NE(-1, IGNORE_EINTR(close(stop_pipe[1]))); | 165 EXPECT_NE(-1, IGNORE_EINTR(close(stop_pipe[1]))); |
167 EXPECT_NE(-1, IGNORE_EINTR(close(pt_pipe[1]))); | 166 EXPECT_NE(-1, IGNORE_EINTR(close(pt_pipe[1]))); |
168 } | 167 } |
169 | 168 |
170 private: | 169 private: |
171 base::Closure test_case_done_callback_; | 170 base::Closure test_case_done_callback_; |
172 base::MessageLoop message_loop_; | 171 base::MessageLoop message_loop_; |
173 scoped_ptr<base::Thread> output_watch_thread_; | 172 scoped_ptr<base::Thread> output_watch_thread_; |
174 bool output_watch_thread_started_; | 173 bool output_watch_thread_started_; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // This will send '\0' to output watcher. | 308 // This will send '\0' to output watcher. |
310 test_cases.push_back(TestCase("", true)); | 309 test_cases.push_back(TestCase("", true)); |
311 // Let's verify that next input also gets detected (i.e. output watcher does | 310 // Let's verify that next input also gets detected (i.e. output watcher does |
312 // not exit after seeing '\0' from previous test case). | 311 // not exit after seeing '\0' from previous test case). |
313 test_cases.push_back(TestCase("a", true)); | 312 test_cases.push_back(TestCase("a", true)); |
314 | 313 |
315 RunTest(test_cases); | 314 RunTest(test_cases); |
316 } | 315 } |
317 | 316 |
318 } // namespace chromeos | 317 } // namespace chromeos |
OLD | NEW |