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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 pt_pipe[0], stop_pipe[0], test_cases)); | 111 pt_pipe[0], stop_pipe[0], test_cases)); |
112 | 112 |
113 for (size_t i = 0; i < test_cases.size(); i++) { | 113 for (size_t i = 0; i < test_cases.size(); i++) { |
114 const std::string& test_str = test_cases[i].str; | 114 const std::string& test_str = test_cases[i].str; |
115 // Let's make inputs not NULL terminated, unless other is specified in | 115 // Let's make inputs not NULL terminated, unless other is specified in |
116 // the test case. | 116 // the test case. |
117 ssize_t test_size = test_str.length() * sizeof(*test_str.c_str()); | 117 ssize_t test_size = test_str.length() * sizeof(*test_str.c_str()); |
118 if (test_cases[i].should_send_terminating_null) | 118 if (test_cases[i].should_send_terminating_null) |
119 test_size += sizeof(*test_str.c_str()); | 119 test_size += sizeof(*test_str.c_str()); |
120 EXPECT_EQ(test_size, | 120 EXPECT_EQ(test_size, |
121 file_util::WriteFileDescriptor(pt_pipe[1], test_str.c_str(), | 121 base::WriteFileDescriptor(pt_pipe[1], test_str.c_str(), |
122 test_size)); | 122 test_size)); |
123 } | 123 } |
124 | 124 |
125 all_data_received_->Wait(); | 125 all_data_received_->Wait(); |
126 | 126 |
127 // Send stop signal. It is not important which string we send. | 127 // Send stop signal. It is not important which string we send. |
128 EXPECT_EQ(1, file_util::WriteFileDescriptor(stop_pipe[1], "q", 1)); | 128 EXPECT_EQ(1, base::WriteFileDescriptor(stop_pipe[1], "q", 1)); |
129 | 129 |
130 EXPECT_NE(-1, IGNORE_EINTR(close(stop_pipe[1]))); | 130 EXPECT_NE(-1, IGNORE_EINTR(close(stop_pipe[1]))); |
131 EXPECT_NE(-1, IGNORE_EINTR(close(pt_pipe[1]))); | 131 EXPECT_NE(-1, IGNORE_EINTR(close(pt_pipe[1]))); |
132 | 132 |
133 output_watch_thread.Stop(); | 133 output_watch_thread.Stop(); |
134 } | 134 } |
135 | 135 |
136 scoped_ptr<base::WaitableEvent> all_data_received_; | 136 scoped_ptr<base::WaitableEvent> all_data_received_; |
137 | 137 |
138 private: | 138 private: |
(...skipping 23 matching lines...) Expand all Loading... |
162 // This will send '\0' to output wathcer. | 162 // This will send '\0' to output wathcer. |
163 test_cases.push_back(TestCase("", true)); | 163 test_cases.push_back(TestCase("", true)); |
164 // Let's verify that next input also gets detected (i.e. output watcher does | 164 // Let's verify that next input also gets detected (i.e. output watcher does |
165 // not exit after seeing '\0' from previous test case). | 165 // not exit after seeing '\0' from previous test case). |
166 test_cases.push_back(TestCase("a", true)); | 166 test_cases.push_back(TestCase("a", true)); |
167 | 167 |
168 RunTest(test_cases); | 168 RunTest(test_cases); |
169 }; | 169 }; |
170 | 170 |
171 } // namespace chromeos | 171 } // namespace chromeos |
OLD | NEW |