| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/blimp_client_context_impl.h" | 5 #include "blimp/client/core/blimp_client_context_impl.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 options.message_loop_type = base::MessageLoop::TYPE_IO; | 28 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 29 io_thread_.StartWithOptions(options); | 29 io_thread_.StartWithOptions(options); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void TearDown() override { | 32 void TearDown() override { |
| 33 io_thread_.Stop(); | 33 io_thread_.Stop(); |
| 34 base::RunLoop().RunUntilIdle(); | 34 base::RunLoop().RunUntilIdle(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 // The thread to use for IO related tasks. | |
| 39 base::Thread io_thread_; | 38 base::Thread io_thread_; |
| 40 | 39 |
| 41 private: | 40 private: |
| 42 // Message loop for the test thread. | |
| 43 base::MessageLoop message_loop_; | 41 base::MessageLoop message_loop_; |
| 44 | 42 |
| 45 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImplTest); | 43 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImplTest); |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 TEST_F(BlimpClientContextImplTest, CreatedBlimpContentsGetsHelpersAttached) { | 46 TEST_F(BlimpClientContextImplTest, CreatedBlimpContentsGetsHelpersAttached) { |
| 49 BlimpClientContextImpl blimp_client_context(io_thread_.task_runner()); | 47 BlimpClientContextImpl blimp_client_context(io_thread_.task_runner(), |
| 48 io_thread_.task_runner()); |
| 50 TestBlimpClientContextDelegate delegate; | 49 TestBlimpClientContextDelegate delegate; |
| 51 blimp_client_context.SetDelegate(&delegate); | 50 blimp_client_context.SetDelegate(&delegate); |
| 52 | 51 |
| 53 BlimpContents* attached_blimp_contents = nullptr; | 52 BlimpContents* attached_blimp_contents = nullptr; |
| 54 | 53 |
| 55 EXPECT_CALL(delegate, AttachBlimpContentsHelpers(testing::_)) | 54 EXPECT_CALL(delegate, AttachBlimpContentsHelpers(testing::_)) |
| 56 .WillOnce(testing::SaveArg<0>(&attached_blimp_contents)) | 55 .WillOnce(testing::SaveArg<0>(&attached_blimp_contents)) |
| 57 .RetiresOnSaturation(); | 56 .RetiresOnSaturation(); |
| 58 | 57 |
| 59 std::unique_ptr<BlimpContents> blimp_contents = | 58 std::unique_ptr<BlimpContents> blimp_contents = |
| 60 blimp_client_context.CreateBlimpContents(); | 59 blimp_client_context.CreateBlimpContents(); |
| 61 DCHECK(blimp_contents); | 60 DCHECK(blimp_contents); |
| 62 DCHECK_EQ(blimp_contents.get(), attached_blimp_contents); | 61 DCHECK_EQ(blimp_contents.get(), attached_blimp_contents); |
| 63 } | 62 } |
| 64 | 63 |
| 65 } // namespace | 64 } // namespace |
| 66 } // namespace client | 65 } // namespace client |
| 67 } // namespace blimp | 66 } // namespace blimp |
| OLD | NEW |