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

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

Issue 2292343002: Hooking up Blimp IME with BlimpContents (Closed)
Patch Set: Fixed linux client 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_manager.h" 5 #include "blimp/client/core/contents/blimp_contents_manager.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_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/blimp_contents_impl.h" 10 #include "blimp/client/core/contents/blimp_contents_impl.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/support/compositor/mock_compositor_dependencies.h" 14 #include "blimp/client/support/compositor/mock_compositor_dependencies.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 18
18 #if defined(OS_ANDROID) 19 #if defined(OS_ANDROID)
19 #include "ui/android/window_android.h" 20 #include "ui/android/window_android.h"
20 #endif // defined(OS_ANDROID) 21 #endif // defined(OS_ANDROID)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 54
54 MOCK_METHOD1(CreateTab, void(int)); 55 MOCK_METHOD1(CreateTab, void(int));
55 MOCK_METHOD1(CloseTab, void(int)); 56 MOCK_METHOD1(CloseTab, void(int));
56 57
57 private: 58 private:
58 DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature); 59 DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature);
59 }; 60 };
60 61
61 TEST_F(BlimpContentsManagerTest, GetExistingBlimpContents) { 62 TEST_F(BlimpContentsManagerTest, GetExistingBlimpContents) {
62 base::MessageLoop loop; 63 base::MessageLoop loop;
64 ImeFeature ime_feature;
63 RenderWidgetFeature render_widget_feature; 65 RenderWidgetFeature render_widget_feature;
64 MockTabControlFeature tab_control_feature; 66 MockTabControlFeature tab_control_feature;
65 67
66 BlimpCompositorDependencies compositor_deps( 68 BlimpCompositorDependencies compositor_deps(
67 base::MakeUnique<MockCompositorDependencies>()); 69 base::MakeUnique<MockCompositorDependencies>());
68 BlimpContentsManager blimp_contents_manager(&compositor_deps, nullptr, 70 BlimpContentsManager blimp_contents_manager(&compositor_deps, &ime_feature,
69 nullptr, &render_widget_feature, 71 nullptr, &render_widget_feature,
70 &tab_control_feature); 72 &tab_control_feature);
71 73
72 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1); 74 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1);
73 std::unique_ptr<BlimpContentsImpl> blimp_contents = 75 std::unique_ptr<BlimpContentsImpl> blimp_contents =
74 blimp_contents_manager.CreateBlimpContents(window_); 76 blimp_contents_manager.CreateBlimpContents(window_);
75 int id = blimp_contents->id(); 77 int id = blimp_contents->id();
76 BlimpContentsImpl* existing_contents = 78 BlimpContentsImpl* existing_contents =
77 blimp_contents_manager.GetBlimpContents(id); 79 blimp_contents_manager.GetBlimpContents(id);
78 EXPECT_EQ(blimp_contents.get(), existing_contents); 80 EXPECT_EQ(blimp_contents.get(), existing_contents);
79 } 81 }
80 82
81 TEST_F(BlimpContentsManagerTest, GetNonExistingBlimpContents) { 83 TEST_F(BlimpContentsManagerTest, GetNonExistingBlimpContents) {
84 ImeFeature ime_feature;
82 RenderWidgetFeature render_widget_feature; 85 RenderWidgetFeature render_widget_feature;
83 MockTabControlFeature tab_control_feature; 86 MockTabControlFeature tab_control_feature;
84 87
85 BlimpCompositorDependencies compositor_deps( 88 BlimpCompositorDependencies compositor_deps(
86 base::MakeUnique<MockCompositorDependencies>()); 89 base::MakeUnique<MockCompositorDependencies>());
87 BlimpContentsManager blimp_contents_manager(&compositor_deps, nullptr, 90 BlimpContentsManager blimp_contents_manager(&compositor_deps, &ime_feature,
88 nullptr, &render_widget_feature, 91 nullptr, &render_widget_feature,
89 &tab_control_feature); 92 &tab_control_feature);
90 93
91 BlimpContentsImpl* existing_contents = 94 BlimpContentsImpl* existing_contents =
92 blimp_contents_manager.GetBlimpContents(kDummyTabId); 95 blimp_contents_manager.GetBlimpContents(kDummyTabId);
93 EXPECT_EQ(nullptr, existing_contents); 96 EXPECT_EQ(nullptr, existing_contents);
94 } 97 }
95 98
96 TEST_F(BlimpContentsManagerTest, GetDestroyedBlimpContents) { 99 TEST_F(BlimpContentsManagerTest, GetDestroyedBlimpContents) {
97 base::MessageLoop loop; 100 base::MessageLoop loop;
101 ImeFeature ime_feature;
98 RenderWidgetFeature render_widget_feature; 102 RenderWidgetFeature render_widget_feature;
99 MockTabControlFeature tab_control_feature; 103 MockTabControlFeature tab_control_feature;
100 BlimpCompositorDependencies compositor_deps( 104 BlimpCompositorDependencies compositor_deps(
101 base::MakeUnique<MockCompositorDependencies>()); 105 base::MakeUnique<MockCompositorDependencies>());
102 BlimpContentsManager blimp_contents_manager(&compositor_deps, nullptr, 106 BlimpContentsManager blimp_contents_manager(&compositor_deps, &ime_feature,
103 nullptr, &render_widget_feature, 107 nullptr, &render_widget_feature,
104 &tab_control_feature); 108 &tab_control_feature);
105 int id; 109 int id;
106 110
107 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1); 111 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1);
108 std::unique_ptr<BlimpContentsImpl> blimp_contents = 112 std::unique_ptr<BlimpContentsImpl> blimp_contents =
109 blimp_contents_manager.CreateBlimpContents(window_); 113 blimp_contents_manager.CreateBlimpContents(window_);
110 id = blimp_contents.get()->id(); 114 id = blimp_contents.get()->id();
111 BlimpContentsImpl* existing_contents = 115 BlimpContentsImpl* existing_contents =
112 blimp_contents_manager.GetBlimpContents(id); 116 blimp_contents_manager.GetBlimpContents(id);
113 EXPECT_EQ(blimp_contents.get(), existing_contents); 117 EXPECT_EQ(blimp_contents.get(), existing_contents);
114 118
115 EXPECT_CALL(tab_control_feature, CloseTab(id)).Times(1); 119 EXPECT_CALL(tab_control_feature, CloseTab(id)).Times(1);
116 blimp_contents.reset(); 120 blimp_contents.reset();
117 121
118 loop.RunUntilIdle(); 122 loop.RunUntilIdle();
119 EXPECT_EQ(nullptr, blimp_contents_manager.GetBlimpContents(id)); 123 EXPECT_EQ(nullptr, blimp_contents_manager.GetBlimpContents(id));
120 } 124 }
121 125
122 // TODO(mlliu): remove this test case (http://crbug.com/642558) 126 // TODO(mlliu): remove this test case (http://crbug.com/642558)
123 TEST_F(BlimpContentsManagerTest, CreateTwoBlimpContentsDestroyAndCreate) { 127 TEST_F(BlimpContentsManagerTest, CreateTwoBlimpContentsDestroyAndCreate) {
124 base::MessageLoop loop; 128 base::MessageLoop loop;
129 ImeFeature ime_feature;
125 RenderWidgetFeature render_widget_feature; 130 RenderWidgetFeature render_widget_feature;
126 MockTabControlFeature tab_control_feature; 131 MockTabControlFeature tab_control_feature;
127 BlimpCompositorDependencies compositor_deps( 132 BlimpCompositorDependencies compositor_deps(
128 base::MakeUnique<MockCompositorDependencies>()); 133 base::MakeUnique<MockCompositorDependencies>());
129 BlimpContentsManager blimp_contents_manager(&compositor_deps, nullptr, 134 BlimpContentsManager blimp_contents_manager(&compositor_deps, &ime_feature,
130 nullptr, &render_widget_feature, 135 nullptr, &render_widget_feature,
131 &tab_control_feature); 136 &tab_control_feature);
132 137
133 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(2); 138 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(2);
134 std::unique_ptr<BlimpContentsImpl> blimp_contents = 139 std::unique_ptr<BlimpContentsImpl> blimp_contents =
135 blimp_contents_manager.CreateBlimpContents(window_); 140 blimp_contents_manager.CreateBlimpContents(window_);
136 EXPECT_NE(blimp_contents, nullptr); 141 EXPECT_NE(blimp_contents, nullptr);
137 142
138 std::unique_ptr<BlimpContentsImpl> second_blimp_contents = 143 std::unique_ptr<BlimpContentsImpl> second_blimp_contents =
139 blimp_contents_manager.CreateBlimpContents(window_); 144 blimp_contents_manager.CreateBlimpContents(window_);
140 EXPECT_EQ(second_blimp_contents, nullptr); 145 EXPECT_EQ(second_blimp_contents, nullptr);
141 146
142 blimp_contents.reset(); 147 blimp_contents.reset();
143 std::unique_ptr<BlimpContentsImpl> third_blimp_contents = 148 std::unique_ptr<BlimpContentsImpl> third_blimp_contents =
144 blimp_contents_manager.CreateBlimpContents(window_); 149 blimp_contents_manager.CreateBlimpContents(window_);
145 EXPECT_NE(third_blimp_contents, nullptr); 150 EXPECT_NE(third_blimp_contents, nullptr);
146 } 151 }
147 152
148 } // namespace 153 } // namespace
149 } // namespace client 154 } // namespace client
150 } // namespace blimp 155 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698