| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/client/core/blimp_client_context_impl.h" | |
| 6 | |
| 7 #include "base/macros.h" | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 #include "base/message_loop/message_loop.h" | |
| 10 #include "base/run_loop.h" | |
| 11 #include "base/threading/thread.h" | |
| 12 #include "blimp/client/core/contents/blimp_contents_impl.h" | |
| 13 #include "blimp/client/core/contents/tab_control_feature.h" | |
| 14 #include "blimp/client/public/blimp_client_context_delegate.h" | |
| 15 #include "blimp/client/public/contents/blimp_contents.h" | |
| 16 #include "blimp/client/test/compositor/mock_compositor_dependencies.h" | |
| 17 #include "blimp/client/test/test_blimp_client_context_delegate.h" | |
| 18 #include "testing/gmock/include/gmock/gmock.h" | |
| 19 #include "testing/gtest/include/gtest/gtest.h" | |
| 20 #include "ui/gfx/native_widget_types.h" | |
| 21 | |
| 22 #if defined(OS_ANDROID) | |
| 23 #include "ui/android/window_android.h" | |
| 24 #endif // defined(OS_ANDROID) | |
| 25 | |
| 26 namespace blimp { | |
| 27 namespace client { | |
| 28 namespace { | |
| 29 | |
| 30 class BlimpClientContextImplTest : public testing::Test { | |
| 31 public: | |
| 32 BlimpClientContextImplTest() : io_thread_("BlimpTestIO") {} | |
| 33 ~BlimpClientContextImplTest() override {} | |
| 34 | |
| 35 void SetUp() override { | |
| 36 base::Thread::Options options; | |
| 37 options.message_loop_type = base::MessageLoop::TYPE_IO; | |
| 38 io_thread_.StartWithOptions(options); | |
| 39 #if defined(OS_ANDROID) | |
| 40 window_ = ui::WindowAndroid::CreateForTesting(); | |
| 41 #endif // defined(OS_ANDROID) | |
| 42 } | |
| 43 | |
| 44 void TearDown() override { | |
| 45 io_thread_.Stop(); | |
| 46 base::RunLoop().RunUntilIdle(); | |
| 47 #if defined(OS_ANDROID) | |
| 48 window_->DestroyForTesting(); | |
| 49 #endif // defined(OS_ANDROID) | |
| 50 } | |
| 51 | |
| 52 protected: | |
| 53 base::Thread io_thread_; | |
| 54 gfx::NativeWindow window_ = nullptr; | |
| 55 | |
| 56 private: | |
| 57 base::MessageLoop message_loop_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImplTest); | |
| 60 }; | |
| 61 | |
| 62 TEST_F(BlimpClientContextImplTest, | |
| 63 CreatedBlimpContentsGetsHelpersAttachedAndHasTabControlFeature) { | |
| 64 BlimpClientContextImpl blimp_client_context( | |
| 65 io_thread_.task_runner(), io_thread_.task_runner(), | |
| 66 base::MakeUnique<MockCompositorDependencies>()); | |
| 67 TestBlimpClientContextDelegate delegate; | |
| 68 blimp_client_context.SetDelegate(&delegate); | |
| 69 | |
| 70 BlimpContents* attached_blimp_contents = nullptr; | |
| 71 | |
| 72 EXPECT_CALL(delegate, AttachBlimpContentsHelpers(testing::_)) | |
| 73 .WillOnce(testing::SaveArg<0>(&attached_blimp_contents)) | |
| 74 .RetiresOnSaturation(); | |
| 75 | |
| 76 std::unique_ptr<BlimpContents> blimp_contents = | |
| 77 blimp_client_context.CreateBlimpContents(window_); | |
| 78 DCHECK(blimp_contents); | |
| 79 DCHECK_EQ(blimp_contents.get(), attached_blimp_contents); | |
| 80 } | |
| 81 | |
| 82 } // namespace | |
| 83 } // namespace client | |
| 84 } // namespace blimp | |
| OLD | NEW |