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 "blimp/client/core/contents/fake_navigation_feature.h" | 9 #include "blimp/client/core/contents/fake_navigation_feature.h" |
9 #include "blimp/client/core/contents/tab_control_feature.h" | 10 #include "blimp/client/core/contents/tab_control_feature.h" |
10 #include "blimp/client/public/contents/blimp_contents_observer.h" | 11 #include "blimp/client/public/contents/blimp_contents_observer.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace blimp { | 15 namespace blimp { |
15 namespace client { | 16 namespace client { |
16 namespace { | 17 namespace { |
17 | 18 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 feature.SetDelegate(1, &navigation_controller); | 52 feature.SetDelegate(1, &navigation_controller); |
52 navigation_controller.SetNavigationFeatureForTesting(&feature); | 53 navigation_controller.SetNavigationFeatureForTesting(&feature); |
53 | 54 |
54 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents); | 55 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents); |
55 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents); | 56 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents); |
56 | 57 |
57 EXPECT_CALL(observer1, OnNavigationStateChanged()); | 58 EXPECT_CALL(observer1, OnNavigationStateChanged()); |
58 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2); | 59 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2); |
59 | 60 |
60 navigation_controller.LoadURL(GURL(kExampleURL)); | 61 navigation_controller.LoadURL(GURL(kExampleURL)); |
61 loop.RunUntilIdle(); | 62 base::RunLoop().RunUntilIdle(); |
62 | 63 |
63 EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec()); | 64 EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec()); |
64 | 65 |
65 // Observer should no longer receive callbacks. | 66 // Observer should no longer receive callbacks. |
66 blimp_contents.RemoveObserver(&observer1); | 67 blimp_contents.RemoveObserver(&observer1); |
67 | 68 |
68 navigation_controller.LoadURL(GURL(kOtherExampleURL)); | 69 navigation_controller.LoadURL(GURL(kOtherExampleURL)); |
69 loop.RunUntilIdle(); | 70 base::RunLoop().RunUntilIdle(); |
70 | 71 |
71 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec()); | 72 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec()); |
72 } | 73 } |
73 | 74 |
74 TEST(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) { | 75 TEST(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) { |
75 int width = 10; | 76 int width = 10; |
76 int height = 15; | 77 int height = 15; |
77 float dp_to_px = 1.23f; | 78 float dp_to_px = 1.23f; |
78 | 79 |
79 MockTabControlFeature tab_control_feature; | 80 MockTabControlFeature tab_control_feature; |
80 base::MessageLoop loop; | 81 base::MessageLoop loop; |
81 BlimpContentsImpl blimp_contents(kDummyTabId, &tab_control_feature); | 82 BlimpContentsImpl blimp_contents(kDummyTabId, &tab_control_feature); |
82 | 83 |
83 EXPECT_CALL(tab_control_feature, | 84 EXPECT_CALL(tab_control_feature, |
84 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1); | 85 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1); |
85 | 86 |
86 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px); | 87 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px); |
87 } | 88 } |
88 | 89 |
89 } // namespace | 90 } // namespace |
90 } // namespace client | 91 } // namespace client |
91 } // namespace blimp | 92 } // namespace blimp |
OLD | NEW |