| 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/contents/blimp_contents_impl.h" | 5 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | 9 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" |
| 10 #include "blimp/client/core/contents/fake_navigation_feature.h" | 10 #include "blimp/client/core/contents/fake_navigation_feature.h" |
| 11 #include "blimp/client/core/contents/ime_feature.h" |
| 11 #include "blimp/client/core/contents/tab_control_feature.h" | 12 #include "blimp/client/core/contents/tab_control_feature.h" |
| 12 #include "blimp/client/core/render_widget/render_widget_feature.h" | 13 #include "blimp/client/core/render_widget/render_widget_feature.h" |
| 13 #include "blimp/client/public/contents/blimp_contents_observer.h" | 14 #include "blimp/client/public/contents/blimp_contents_observer.h" |
| 14 #include "blimp/client/support/compositor/mock_compositor_dependencies.h" | 15 #include "blimp/client/support/compositor/mock_compositor_dependencies.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 18 | 19 |
| 19 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
| 20 #include "ui/android/window_android.h" | 21 #include "ui/android/window_android.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 63 |
| 63 protected: | 64 protected: |
| 64 gfx::NativeWindow window_ = nullptr; | 65 gfx::NativeWindow window_ = nullptr; |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(BlimpContentsImplTest); | 68 DISALLOW_COPY_AND_ASSIGN(BlimpContentsImplTest); |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 TEST_F(BlimpContentsImplTest, LoadURLAndNotifyObservers) { | 71 TEST_F(BlimpContentsImplTest, LoadURLAndNotifyObservers) { |
| 71 base::MessageLoop loop; | 72 base::MessageLoop loop; |
| 73 ImeFeature ime_feature; |
| 72 FakeNavigationFeature navigation_feature; | 74 FakeNavigationFeature navigation_feature; |
| 73 RenderWidgetFeature render_widget_feature; | 75 RenderWidgetFeature render_widget_feature; |
| 74 BlimpCompositorDependencies compositor_deps( | 76 BlimpCompositorDependencies compositor_deps( |
| 75 base::MakeUnique<MockCompositorDependencies>()); | 77 base::MakeUnique<MockCompositorDependencies>()); |
| 76 BlimpContentsImpl blimp_contents(kDummyTabId, window_, &compositor_deps, | 78 BlimpContentsImpl blimp_contents(kDummyTabId, window_, &compositor_deps, |
| 77 nullptr, &navigation_feature, | 79 &ime_feature, &navigation_feature, |
| 78 &render_widget_feature, nullptr); | 80 &render_widget_feature, nullptr); |
| 79 | 81 |
| 80 BlimpNavigationControllerImpl& navigation_controller = | 82 BlimpNavigationControllerImpl& navigation_controller = |
| 81 blimp_contents.GetNavigationController(); | 83 blimp_contents.GetNavigationController(); |
| 82 | 84 |
| 83 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents); | 85 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents); |
| 84 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents); | 86 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents); |
| 85 | 87 |
| 86 EXPECT_CALL(observer1, OnNavigationStateChanged()); | 88 EXPECT_CALL(observer1, OnNavigationStateChanged()); |
| 87 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2); | 89 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 98 base::RunLoop().RunUntilIdle(); | 100 base::RunLoop().RunUntilIdle(); |
| 99 | 101 |
| 100 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec()); | 102 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec()); |
| 101 } | 103 } |
| 102 | 104 |
| 103 TEST_F(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) { | 105 TEST_F(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) { |
| 104 int width = 10; | 106 int width = 10; |
| 105 int height = 15; | 107 int height = 15; |
| 106 float dp_to_px = 1.23f; | 108 float dp_to_px = 1.23f; |
| 107 | 109 |
| 110 ImeFeature ime_feature; |
| 108 RenderWidgetFeature render_widget_feature; | 111 RenderWidgetFeature render_widget_feature; |
| 109 MockTabControlFeature tab_control_feature; | 112 MockTabControlFeature tab_control_feature; |
| 110 base::MessageLoop loop; | 113 base::MessageLoop loop; |
| 111 BlimpCompositorDependencies compositor_deps( | 114 BlimpCompositorDependencies compositor_deps( |
| 112 base::MakeUnique<MockCompositorDependencies>()); | 115 base::MakeUnique<MockCompositorDependencies>()); |
| 113 BlimpContentsImpl blimp_contents(kDummyTabId, window_, &compositor_deps, | 116 BlimpContentsImpl blimp_contents( |
| 114 nullptr, nullptr, &render_widget_feature, | 117 kDummyTabId, window_, &compositor_deps, &ime_feature, nullptr, |
| 115 &tab_control_feature); | 118 &render_widget_feature, &tab_control_feature); |
| 116 | 119 |
| 117 EXPECT_CALL(tab_control_feature, | 120 EXPECT_CALL(tab_control_feature, |
| 118 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1); | 121 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1); |
| 119 | 122 |
| 120 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px); | 123 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px); |
| 121 } | 124 } |
| 122 | 125 |
| 123 } // namespace | 126 } // namespace |
| 124 } // namespace client | 127 } // namespace client |
| 125 } // namespace blimp | 128 } // namespace blimp |
| OLD | NEW |