| 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 "blimp/client/core/contents/fake_navigation_feature.h" | 8 #include "blimp/client/core/contents/fake_navigation_feature.h" |
| 9 #include "blimp/client/core/contents/tab_control_feature.h" | 9 #include "blimp/client/core/contents/tab_control_feature.h" |
| 10 #include "blimp/client/public/contents/blimp_contents_observer.h" | 10 #include "blimp/client/public/contents/blimp_contents_observer.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 MockTabControlFeature() {} | 36 MockTabControlFeature() {} |
| 37 ~MockTabControlFeature() override = default; | 37 ~MockTabControlFeature() override = default; |
| 38 MOCK_METHOD2(SetSizeAndScale, void(const gfx::Size&, float)); | 38 MOCK_METHOD2(SetSizeAndScale, void(const gfx::Size&, float)); |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature); | 41 DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 TEST(BlimpContentsImplTest, LoadURLAndNotifyObservers) { | 44 TEST(BlimpContentsImplTest, LoadURLAndNotifyObservers) { |
| 45 base::MessageLoop loop; | 45 base::MessageLoop loop; |
| 46 BlimpContentsImpl blimp_contents(kDummyTabId, nullptr); | 46 FakeNavigationFeature feature; |
| 47 BlimpContentsImpl blimp_contents(kDummyTabId, nullptr, &feature, nullptr); |
| 47 | 48 |
| 48 BlimpNavigationControllerImpl& navigation_controller = | 49 BlimpNavigationControllerImpl& navigation_controller = |
| 49 blimp_contents.GetNavigationController(); | 50 blimp_contents.GetNavigationController(); |
| 50 FakeNavigationFeature feature; | |
| 51 feature.SetDelegate(1, &navigation_controller); | |
| 52 navigation_controller.SetNavigationFeatureForTesting(&feature); | |
| 53 | 51 |
| 54 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents); | 52 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents); |
| 55 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents); | 53 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents); |
| 56 | 54 |
| 57 EXPECT_CALL(observer1, OnNavigationStateChanged()); | 55 EXPECT_CALL(observer1, OnNavigationStateChanged()); |
| 58 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2); | 56 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2); |
| 59 | 57 |
| 60 navigation_controller.LoadURL(GURL(kExampleURL)); | 58 navigation_controller.LoadURL(GURL(kExampleURL)); |
| 61 loop.RunUntilIdle(); | 59 loop.RunUntilIdle(); |
| 62 | 60 |
| 63 EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec()); | 61 EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec()); |
| 64 | 62 |
| 65 // Observer should no longer receive callbacks. | 63 // Observer should no longer receive callbacks. |
| 66 blimp_contents.RemoveObserver(&observer1); | 64 blimp_contents.RemoveObserver(&observer1); |
| 67 | 65 |
| 68 navigation_controller.LoadURL(GURL(kOtherExampleURL)); | 66 navigation_controller.LoadURL(GURL(kOtherExampleURL)); |
| 69 loop.RunUntilIdle(); | 67 loop.RunUntilIdle(); |
| 70 | 68 |
| 71 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec()); | 69 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec()); |
| 72 } | 70 } |
| 73 | 71 |
| 74 TEST(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) { | 72 TEST(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) { |
| 75 int width = 10; | 73 int width = 10; |
| 76 int height = 15; | 74 int height = 15; |
| 77 float dp_to_px = 1.23f; | 75 float dp_to_px = 1.23f; |
| 78 | 76 |
| 79 MockTabControlFeature tab_control_feature; | 77 MockTabControlFeature tab_control_feature; |
| 80 base::MessageLoop loop; | 78 base::MessageLoop loop; |
| 81 BlimpContentsImpl blimp_contents(kDummyTabId, &tab_control_feature); | 79 BlimpContentsImpl blimp_contents(kDummyTabId, nullptr, nullptr, |
| 80 &tab_control_feature); |
| 82 | 81 |
| 83 EXPECT_CALL(tab_control_feature, | 82 EXPECT_CALL(tab_control_feature, |
| 84 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1); | 83 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1); |
| 85 | 84 |
| 86 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px); | 85 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px); |
| 87 } | 86 } |
| 88 | 87 |
| 89 } // namespace | 88 } // namespace |
| 90 } // namespace client | 89 } // namespace client |
| 91 } // namespace blimp | 90 } // namespace blimp |
| OLD | NEW |