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

Side by Side Diff: ui/views/corewm/desktop_capture_controller_unittest.cc

Issue 2466023003: Makes CaptureController be created and owned by WMState (Closed)
Patch Set: moar Created 4 years, 1 month 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 | « ash/test/ash_test_helper.cc ('k') | ui/views/test/views_test_helper_aura.cc » ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/wm/core/capture_controller.h" 5 #include "ui/wm/core/capture_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/aura/env.h" 9 #include "ui/aura/env.h"
10 #include "ui/aura/test/test_window_delegate.h" 10 #include "ui/aura/test/test_window_delegate.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // the window which had capture receives the gesture. 93 // the window which had capture receives the gesture.
94 // TODO(sky): move this test, it should be part of ScopedCaptureClient tests. 94 // TODO(sky): move this test, it should be part of ScopedCaptureClient tests.
95 TEST_F(DesktopCaptureControllerTest, CaptureWindowInputEventTest) { 95 TEST_F(DesktopCaptureControllerTest, CaptureWindowInputEventTest) {
96 std::unique_ptr<aura::client::ScreenPositionClient> desktop_position_client1; 96 std::unique_ptr<aura::client::ScreenPositionClient> desktop_position_client1;
97 std::unique_ptr<aura::client::ScreenPositionClient> desktop_position_client2; 97 std::unique_ptr<aura::client::ScreenPositionClient> desktop_position_client2;
98 98
99 std::unique_ptr<Widget> widget1(new Widget()); 99 std::unique_ptr<Widget> widget1(new Widget());
100 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 100 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
101 std::unique_ptr<wm::ScopedCaptureClient> scoped_capture_client( 101 std::unique_ptr<wm::ScopedCaptureClient> scoped_capture_client(
102 new wm::ScopedCaptureClient(params.context->GetRootWindow())); 102 new wm::ScopedCaptureClient(params.context->GetRootWindow()));
103 aura::client::CaptureClient* capture_client = 103 aura::client::CaptureClient* capture_client = wm::CaptureController::Get();
104 scoped_capture_client->capture_client();
105 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 104 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
106 params.bounds = gfx::Rect(50, 50, 650, 650); 105 params.bounds = gfx::Rect(50, 50, 650, 650);
107 widget1->Init(params); 106 widget1->Init(params);
108 internal::RootView* root1 = 107 internal::RootView* root1 =
109 static_cast<internal::RootView*>(widget1->GetRootView()); 108 static_cast<internal::RootView*>(widget1->GetRootView());
110 109
111 desktop_position_client1.reset( 110 desktop_position_client1.reset(
112 new DesktopScreenPositionClient(params.context->GetRootWindow())); 111 new DesktopScreenPositionClient(params.context->GetRootWindow()));
113 aura::client::SetScreenPositionClient( 112 aura::client::SetScreenPositionClient(
114 widget1->GetNativeView()->GetRootWindow(), 113 widget1->GetNativeView()->GetRootWindow(),
(...skipping 20 matching lines...) Expand all
135 desktop_position_client2.get()); 134 desktop_position_client2.get());
136 ui::EventDispatchDetails details; 135 ui::EventDispatchDetails details;
137 136
138 DesktopViewInputTest* v2 = new DesktopViewInputTest(); 137 DesktopViewInputTest* v2 = new DesktopViewInputTest();
139 v2->SetBoundsRect(gfx::Rect(0, 0, 300, 300)); 138 v2->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
140 root2->AddChildView(v2); 139 root2->AddChildView(v2);
141 widget2->Show(); 140 widget2->Show();
142 141
143 EXPECT_FALSE(widget1->GetNativeView()->HasCapture()); 142 EXPECT_FALSE(widget1->GetNativeView()->HasCapture());
144 EXPECT_FALSE(widget2->GetNativeView()->HasCapture()); 143 EXPECT_FALSE(widget2->GetNativeView()->HasCapture());
145 EXPECT_EQ(reinterpret_cast<aura::Window*>(0), 144 EXPECT_EQ(nullptr, capture_client->GetCaptureWindow());
146 capture_client->GetCaptureWindow());
147 145
148 widget1->GetNativeView()->SetCapture(); 146 widget1->GetNativeView()->SetCapture();
149 EXPECT_TRUE(widget1->GetNativeView()->HasCapture()); 147 EXPECT_TRUE(widget1->GetNativeView()->HasCapture());
150 EXPECT_FALSE(widget2->GetNativeView()->HasCapture()); 148 EXPECT_FALSE(widget2->GetNativeView()->HasCapture());
151 EXPECT_EQ(capture_client->GetCaptureWindow(), widget1->GetNativeView()); 149 EXPECT_EQ(capture_client->GetCaptureWindow(), widget1->GetNativeView());
152 150
153 ui::GestureEvent g1(80, 80, 0, base::TimeTicks(), 151 ui::GestureEvent g1(80, 80, 0, base::TimeTicks(),
154 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 152 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
155 details = root1->OnEventFromSource(&g1); 153 details = root1->OnEventFromSource(&g1);
156 EXPECT_FALSE(details.dispatcher_destroyed); 154 EXPECT_FALSE(details.dispatcher_destroyed);
(...skipping 16 matching lines...) Expand all
173 171
174 EXPECT_TRUE(v2->received_gesture_event()); 172 EXPECT_TRUE(v2->received_gesture_event());
175 EXPECT_FALSE(v1->received_gesture_event()); 173 EXPECT_FALSE(v1->received_gesture_event());
176 174
177 widget1->CloseNow(); 175 widget1->CloseNow();
178 widget2->CloseNow(); 176 widget2->CloseNow();
179 RunPendingMessages(); 177 RunPendingMessages();
180 } 178 }
181 179
182 } // namespace views 180 } // namespace views
OLDNEW
« no previous file with comments | « ash/test/ash_test_helper.cc ('k') | ui/views/test/views_test_helper_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698