Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: blimp/client/core/contents/blimp_contents_impl_unittest.cc

Issue 2292723003: Move remaining Blimp feature code to core. (Closed)
Patch Set: Fix build break Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/contents/fake_navigation_feature.h" 10 #include "blimp/client/core/contents/fake_navigation_feature.h"
10 #include "blimp/client/core/contents/tab_control_feature.h" 11 #include "blimp/client/core/contents/tab_control_feature.h"
12 #include "blimp/client/core/render_widget/render_widget_feature.h"
11 #include "blimp/client/public/contents/blimp_contents_observer.h" 13 #include "blimp/client/public/contents/blimp_contents_observer.h"
14 #include "blimp/client/support/compositor/mock_compositor_dependencies.h"
12 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
14 17
15 namespace blimp { 18 namespace blimp {
16 namespace client { 19 namespace client {
17 namespace { 20 namespace {
18 21
19 const char kExampleURL[] = "https://www.example.com/"; 22 const char kExampleURL[] = "https://www.example.com/";
20 const char kOtherExampleURL[] = "https://www.otherexample.com/"; 23 const char kOtherExampleURL[] = "https://www.otherexample.com/";
21 const int kDummyTabId = 0; 24 const int kDummyTabId = 0;
(...skipping 15 matching lines...) Expand all
37 MockTabControlFeature() {} 40 MockTabControlFeature() {}
38 ~MockTabControlFeature() override = default; 41 ~MockTabControlFeature() override = default;
39 MOCK_METHOD2(SetSizeAndScale, void(const gfx::Size&, float)); 42 MOCK_METHOD2(SetSizeAndScale, void(const gfx::Size&, float));
40 43
41 private: 44 private:
42 DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature); 45 DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature);
43 }; 46 };
44 47
45 TEST(BlimpContentsImplTest, LoadURLAndNotifyObservers) { 48 TEST(BlimpContentsImplTest, LoadURLAndNotifyObservers) {
46 base::MessageLoop loop; 49 base::MessageLoop loop;
47 FakeNavigationFeature feature; 50 FakeNavigationFeature navigation_feature;
48 BlimpContentsImpl blimp_contents(kDummyTabId, nullptr, &feature, nullptr); 51 RenderWidgetFeature render_widget_feature;
52 BlimpCompositorDependencies compositor_deps(
53 base::MakeUnique<MockCompositorDependencies>());
54 BlimpContentsImpl blimp_contents(kDummyTabId, &compositor_deps, nullptr,
55 &navigation_feature, &render_widget_feature,
56 nullptr);
49 57
50 BlimpNavigationControllerImpl& navigation_controller = 58 BlimpNavigationControllerImpl& navigation_controller =
51 blimp_contents.GetNavigationController(); 59 blimp_contents.GetNavigationController();
52 60
53 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents); 61 testing::StrictMock<MockBlimpContentsObserver> observer1(&blimp_contents);
54 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents); 62 testing::StrictMock<MockBlimpContentsObserver> observer2(&blimp_contents);
55 63
56 EXPECT_CALL(observer1, OnNavigationStateChanged()); 64 EXPECT_CALL(observer1, OnNavigationStateChanged());
57 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2); 65 EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2);
58 66
59 navigation_controller.LoadURL(GURL(kExampleURL)); 67 navigation_controller.LoadURL(GURL(kExampleURL));
60 base::RunLoop().RunUntilIdle(); 68 base::RunLoop().RunUntilIdle();
61 69
62 EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec()); 70 EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec());
63 71
64 // Observer should no longer receive callbacks. 72 // Observer should no longer receive callbacks.
65 blimp_contents.RemoveObserver(&observer1); 73 blimp_contents.RemoveObserver(&observer1);
66 74
67 navigation_controller.LoadURL(GURL(kOtherExampleURL)); 75 navigation_controller.LoadURL(GURL(kOtherExampleURL));
68 base::RunLoop().RunUntilIdle(); 76 base::RunLoop().RunUntilIdle();
69 77
70 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec()); 78 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec());
71 } 79 }
72 80
73 TEST(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) { 81 TEST(BlimpContentsImplTest, SetSizeAndScaleThroughTabControlFeature) {
74 int width = 10; 82 int width = 10;
75 int height = 15; 83 int height = 15;
76 float dp_to_px = 1.23f; 84 float dp_to_px = 1.23f;
77 85
86 RenderWidgetFeature render_widget_feature;
78 MockTabControlFeature tab_control_feature; 87 MockTabControlFeature tab_control_feature;
79 base::MessageLoop loop; 88 base::MessageLoop loop;
80 BlimpContentsImpl blimp_contents(kDummyTabId, nullptr, nullptr, 89 BlimpCompositorDependencies compositor_deps(
90 base::MakeUnique<MockCompositorDependencies>());
91 BlimpContentsImpl blimp_contents(kDummyTabId, &compositor_deps, nullptr,
92 nullptr, &render_widget_feature,
81 &tab_control_feature); 93 &tab_control_feature);
82 94
83 EXPECT_CALL(tab_control_feature, 95 EXPECT_CALL(tab_control_feature,
84 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1); 96 SetSizeAndScale(gfx::Size(width, height), dp_to_px)).Times(1);
85 97
86 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px); 98 blimp_contents.SetSizeAndScale(gfx::Size(width, height), dp_to_px);
87 } 99 }
88 100
89 } // namespace 101 } // namespace
90 } // namespace client 102 } // namespace client
91 } // namespace blimp 103 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/blimp_contents_impl.cc ('k') | blimp/client/core/contents/blimp_contents_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698