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

Side by Side Diff: ui/views/mus/desktop_window_tree_host_mus_unittest.cc

Issue 2626013005: Change CaptureSynchronizer and PointerWatcherEventRouter to support multiple CaptureClients. (Closed)
Patch Set: comments; sequence; test Created 3 years, 10 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 "ui/views/mus/desktop_window_tree_host_mus.h" 5 #include "ui/views/mus/desktop_window_tree_host_mus.h"
6 6
7 #include "base/debug/stack_trace.h" 7 #include "base/debug/stack_trace.h"
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
11 #include "ui/aura/client/transient_window_client.h" 11 #include "ui/aura/client/transient_window_client.h"
12 #include "ui/aura/mus/capture_synchronizer.h"
12 #include "ui/aura/mus/in_flight_change.h" 13 #include "ui/aura/mus/in_flight_change.h"
14 #include "ui/aura/mus/window_mus.h"
15 #include "ui/aura/mus/window_tree_client.h"
13 #include "ui/aura/test/mus/change_completion_waiter.h" 16 #include "ui/aura/test/mus/change_completion_waiter.h"
14 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
15 #include "ui/views/mus/mus_client.h" 18 #include "ui/views/mus/mus_client.h"
16 #include "ui/views/test/views_test_base.h" 19 #include "ui/views/test/views_test_base.h"
17 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
18 #include "ui/views/widget/widget_delegate.h" 21 #include "ui/views/widget/widget_delegate.h"
19 #include "ui/views/widget/widget_observer.h" 22 #include "ui/views/widget/widget_observer.h"
20 23
21 namespace views { 24 namespace views {
22 25
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 widget->Show(); 120 widget->Show();
118 EXPECT_TRUE(widget->IsVisible()); 121 EXPECT_TRUE(widget->IsVisible());
119 EXPECT_TRUE(widget->GetNativeView()->IsVisible()); 122 EXPECT_TRUE(widget->GetNativeView()->IsVisible());
120 EXPECT_TRUE(widget->GetNativeView()->parent()->IsVisible()); 123 EXPECT_TRUE(widget->GetNativeView()->parent()->IsVisible());
121 widget->Hide(); 124 widget->Hide();
122 EXPECT_FALSE(widget->IsVisible()); 125 EXPECT_FALSE(widget->IsVisible());
123 EXPECT_FALSE(widget->GetNativeView()->IsVisible()); 126 EXPECT_FALSE(widget->GetNativeView()->IsVisible());
124 EXPECT_FALSE(widget->GetNativeView()->parent()->IsVisible()); 127 EXPECT_FALSE(widget->GetNativeView()->parent()->IsVisible());
125 } 128 }
126 129
130 TEST_F(DesktopWindowTreeHostMusTest, Capture) {
131 std::unique_ptr<Widget> widget1(CreateWidget());
132 widget1->Show();
133 EXPECT_FALSE(widget1->HasCapture());
134
135 std::unique_ptr<Widget> widget2(CreateWidget());
136 widget2->Show();
137 EXPECT_FALSE(widget2->HasCapture());
138
139 widget1->SetCapture(widget1->GetRootView());
140 EXPECT_TRUE(widget1->HasCapture());
141 EXPECT_FALSE(widget2->HasCapture());
142 EXPECT_EQ(widget1->GetNativeWindow(),
143 MusClient::Get()
144 ->window_tree_client()
145 ->capture_synchronizer()
146 ->capture_window()
147 ->GetWindow());
148
149 widget2->SetCapture(widget2->GetRootView());
150 EXPECT_TRUE(widget2->HasCapture());
151 EXPECT_EQ(widget2->GetNativeWindow(),
152 MusClient::Get()
153 ->window_tree_client()
154 ->capture_synchronizer()
155 ->capture_window()
156 ->GetWindow());
157
158 widget1->ReleaseCapture();
159 EXPECT_TRUE(widget2->HasCapture());
160 EXPECT_FALSE(widget1->HasCapture());
161 EXPECT_EQ(widget2->GetNativeWindow(),
162 MusClient::Get()
163 ->window_tree_client()
164 ->capture_synchronizer()
165 ->capture_window()
166 ->GetWindow());
167
168 widget2->ReleaseCapture();
169 EXPECT_FALSE(widget2->HasCapture());
170 EXPECT_FALSE(widget1->HasCapture());
171 EXPECT_EQ(nullptr,
172 MusClient::Get()
173 ->window_tree_client()
174 ->capture_synchronizer()
175 ->capture_window());
176 }
177
127 TEST_F(DesktopWindowTreeHostMusTest, Deactivate) { 178 TEST_F(DesktopWindowTreeHostMusTest, Deactivate) {
128 std::unique_ptr<Widget> widget1(CreateWidget()); 179 std::unique_ptr<Widget> widget1(CreateWidget());
129 widget1->Show(); 180 widget1->Show();
130 181
131 std::unique_ptr<Widget> widget2(CreateWidget()); 182 std::unique_ptr<Widget> widget2(CreateWidget());
132 widget2->Show(); 183 widget2->Show();
133 184
134 widget1->Activate(); 185 widget1->Activate();
135 RunPendingMessages(); 186 RunPendingMessages();
136 EXPECT_TRUE(widget1->IsActive()); 187 EXPECT_TRUE(widget1->IsActive());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 aura::client::TransientWindowClient* transient_window_client = 260 aura::client::TransientWindowClient* transient_window_client =
210 aura::client::GetTransientWindowClient(); 261 aura::client::GetTransientWindowClient();
211 // Even though the widget1->GetNativeView() was specified as the parent we 262 // Even though the widget1->GetNativeView() was specified as the parent we
212 // expect the transient parents to be marked at the host level. 263 // expect the transient parents to be marked at the host level.
213 EXPECT_EQ(widget1->GetNativeView()->GetHost()->window(), 264 EXPECT_EQ(widget1->GetNativeView()->GetHost()->window(),
214 transient_window_client->GetTransientParent( 265 transient_window_client->GetTransientParent(
215 widget2->GetNativeView()->GetHost()->window())); 266 widget2->GetNativeView()->GetHost()->window()));
216 } 267 }
217 268
218 } // namespace views 269 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698