| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/web_data_consumer_handle_impl.h" | 5 #include "content/child/web_data_consumer_handle_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 base::MessageLoop message_loop_; | 231 base::MessageLoop message_loop_; |
| 232 | 232 |
| 233 mojo::ScopedDataPipeProducerHandle producer_; | 233 mojo::ScopedDataPipeProducerHandle producer_; |
| 234 mojo::ScopedDataPipeConsumerHandle consumer_; | 234 mojo::ScopedDataPipeConsumerHandle consumer_; |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 TEST_F(WebDataConsumerHandleImplTest, ReadData) { | 237 TEST_F(WebDataConsumerHandleImplTest, ReadData) { |
| 238 base::RunLoop run_loop; | 238 base::RunLoop run_loop; |
| 239 auto operation = base::WrapUnique(new ReadDataOperation( | 239 auto operation = base::MakeUnique<ReadDataOperation>( |
| 240 std::move(consumer_), &message_loop_, run_loop.QuitClosure())); | 240 std::move(consumer_), &message_loop_, run_loop.QuitClosure()); |
| 241 | 241 |
| 242 base::Thread t("DataConsumerHandle test thread"); | 242 base::Thread t("DataConsumerHandle test thread"); |
| 243 ASSERT_TRUE(t.Start()); | 243 ASSERT_TRUE(t.Start()); |
| 244 | 244 |
| 245 t.task_runner()->PostTask(FROM_HERE, | 245 t.task_runner()->PostTask(FROM_HERE, |
| 246 base::Bind(&ReadDataOperation::ReadData, | 246 base::Bind(&ReadDataOperation::ReadData, |
| 247 base::Unretained(operation.get()))); | 247 base::Unretained(operation.get()))); |
| 248 | 248 |
| 249 std::string expected = ProduceData(24 * 1024); | 249 std::string expected = ProduceData(24 * 1024); |
| 250 producer_.reset(); | 250 producer_.reset(); |
| 251 | 251 |
| 252 run_loop.Run(); | 252 run_loop.Run(); |
| 253 t.Stop(); | 253 t.Stop(); |
| 254 | 254 |
| 255 EXPECT_EQ(expected, operation->result()); | 255 EXPECT_EQ(expected, operation->result()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 TEST_F(WebDataConsumerHandleImplTest, TwoPhaseReadData) { | 258 TEST_F(WebDataConsumerHandleImplTest, TwoPhaseReadData) { |
| 259 base::RunLoop run_loop; | 259 base::RunLoop run_loop; |
| 260 auto operation = base::WrapUnique(new TwoPhaseReadDataOperation( | 260 auto operation = base::MakeUnique<TwoPhaseReadDataOperation>( |
| 261 std::move(consumer_), &message_loop_, run_loop.QuitClosure())); | 261 std::move(consumer_), &message_loop_, run_loop.QuitClosure()); |
| 262 | 262 |
| 263 base::Thread t("DataConsumerHandle test thread"); | 263 base::Thread t("DataConsumerHandle test thread"); |
| 264 ASSERT_TRUE(t.Start()); | 264 ASSERT_TRUE(t.Start()); |
| 265 | 265 |
| 266 t.task_runner()->PostTask(FROM_HERE, | 266 t.task_runner()->PostTask(FROM_HERE, |
| 267 base::Bind(&TwoPhaseReadDataOperation::ReadData, | 267 base::Bind(&TwoPhaseReadDataOperation::ReadData, |
| 268 base::Unretained(operation.get()))); | 268 base::Unretained(operation.get()))); |
| 269 | 269 |
| 270 std::string expected = ProduceData(24 * 1024); | 270 std::string expected = ProduceData(24 * 1024); |
| 271 producer_.reset(); | 271 producer_.reset(); |
| 272 | 272 |
| 273 run_loop.Run(); | 273 run_loop.Run(); |
| 274 t.Stop(); | 274 t.Stop(); |
| 275 | 275 |
| 276 EXPECT_EQ(expected, operation->result()); | 276 EXPECT_EQ(expected, operation->result()); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace | 279 } // namespace |
| 280 | 280 |
| 281 } // namespace content | 281 } // namespace content |
| OLD | NEW |