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

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: fix leak in 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
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.cc ('k') | ui/views/mus/mus_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(), MusClient::Get()
143 ->window_tree_client()
144 ->capture_synchronizer()
145 ->capture_window()
146 ->GetWindow());
147
148 widget2->SetCapture(widget2->GetRootView());
149 EXPECT_TRUE(widget2->HasCapture());
150 EXPECT_EQ(widget2->GetNativeWindow(), MusClient::Get()
151 ->window_tree_client()
152 ->capture_synchronizer()
153 ->capture_window()
154 ->GetWindow());
155
156 widget1->ReleaseCapture();
157 EXPECT_TRUE(widget2->HasCapture());
158 EXPECT_FALSE(widget1->HasCapture());
159 EXPECT_EQ(widget2->GetNativeWindow(), MusClient::Get()
160 ->window_tree_client()
161 ->capture_synchronizer()
162 ->capture_window()
163 ->GetWindow());
164
165 widget2->ReleaseCapture();
166 EXPECT_FALSE(widget2->HasCapture());
167 EXPECT_FALSE(widget1->HasCapture());
168 EXPECT_EQ(nullptr, MusClient::Get()
169 ->window_tree_client()
170 ->capture_synchronizer()
171 ->capture_window());
172 }
173
127 TEST_F(DesktopWindowTreeHostMusTest, Deactivate) { 174 TEST_F(DesktopWindowTreeHostMusTest, Deactivate) {
128 std::unique_ptr<Widget> widget1(CreateWidget()); 175 std::unique_ptr<Widget> widget1(CreateWidget());
129 widget1->Show(); 176 widget1->Show();
130 177
131 std::unique_ptr<Widget> widget2(CreateWidget()); 178 std::unique_ptr<Widget> widget2(CreateWidget());
132 widget2->Show(); 179 widget2->Show();
133 180
134 widget1->Activate(); 181 widget1->Activate();
135 RunPendingMessages(); 182 RunPendingMessages();
136 EXPECT_TRUE(widget1->IsActive()); 183 EXPECT_TRUE(widget1->IsActive());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 aura::client::TransientWindowClient* transient_window_client = 256 aura::client::TransientWindowClient* transient_window_client =
210 aura::client::GetTransientWindowClient(); 257 aura::client::GetTransientWindowClient();
211 // Even though the widget1->GetNativeView() was specified as the parent we 258 // Even though the widget1->GetNativeView() was specified as the parent we
212 // expect the transient parents to be marked at the host level. 259 // expect the transient parents to be marked at the host level.
213 EXPECT_EQ(widget1->GetNativeView()->GetHost()->window(), 260 EXPECT_EQ(widget1->GetNativeView()->GetHost()->window(),
214 transient_window_client->GetTransientParent( 261 transient_window_client->GetTransientParent(
215 widget2->GetNativeView()->GetHost()->window())); 262 widget2->GetNativeView()->GetHost()->window()));
216 } 263 }
217 264
218 } // namespace views 265 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.cc ('k') | ui/views/mus/mus_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698