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

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

Issue 1936823002: mus: Don't activate non-activatable widgets on Show() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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/native_widget_mus.cc ('k') | no next file » | 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/native_widget_mus.h" 5 #include "ui/views/mus/native_widget_mus.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "components/mus/public/cpp/property_type_converters.h" 8 #include "components/mus/public/cpp/property_type_converters.h"
9 #include "components/mus/public/cpp/window.h" 9 #include "components/mus/public/cpp/window.h"
10 #include "components/mus/public/cpp/window_property.h" 10 #include "components/mus/public/cpp/window_property.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 // The widget is focused and activated. 126 // The widget is focused and activated.
127 ASSERT_EQ(2u, focus_listener.focus_changes().size()); 127 ASSERT_EQ(2u, focus_listener.focus_changes().size());
128 EXPECT_EQ(widget->GetNativeView(), focus_listener.focus_changes()[1]); 128 EXPECT_EQ(widget->GetNativeView(), focus_listener.focus_changes()[1]);
129 ASSERT_EQ(2u, activation_observer.changes().size()); 129 ASSERT_EQ(2u, activation_observer.changes().size());
130 EXPECT_TRUE(activation_observer.changes()[1]); 130 EXPECT_TRUE(activation_observer.changes()[1]);
131 131
132 WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener); 132 WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener);
133 } 133 }
134 134
135 // Tests that showing a non-activatable widget does not activate it.
136 // TODO(jamescook): Remove this test when widget_interactive_uittests.cc runs
137 // under mus.
138 TEST_F(NativeWidgetMusTest, ShowNonActivatableWidget) {
139 Widget widget;
140 WidgetActivationObserver activation_observer(&widget);
141 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_BUBBLE);
142 params.activatable = Widget::InitParams::ACTIVATABLE_NO;
143 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
144 params.bounds = gfx::Rect(10, 20, 100, 200);
145 widget.Init(params);
146 widget.Show();
147
148 // The widget is not currently active.
149 EXPECT_FALSE(widget.IsActive());
150
151 // The widget was never active.
152 EXPECT_EQ(0u, activation_observer.changes().size());
153 }
154
135 // Tests that a window with an icon sets the mus::Window icon property. 155 // Tests that a window with an icon sets the mus::Window icon property.
136 TEST_F(NativeWidgetMusTest, AppIcon) { 156 TEST_F(NativeWidgetMusTest, AppIcon) {
137 // Create a Widget with a bitmap as the icon. 157 // Create a Widget with a bitmap as the icon.
138 SkBitmap source_bitmap = MakeBitmap(SK_ColorRED); 158 SkBitmap source_bitmap = MakeBitmap(SK_ColorRED);
139 std::unique_ptr<Widget> widget( 159 std::unique_ptr<Widget> widget(
140 CreateWidget(new TestWidgetDelegate(source_bitmap))); 160 CreateWidget(new TestWidgetDelegate(source_bitmap)));
141 161
142 // The mus::Window has the icon property. 162 // The mus::Window has the icon property.
143 mus::Window* window = 163 mus::Window* window =
144 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window(); 164 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 221 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
202 params.name = "MyWidget"; 222 params.name = "MyWidget";
203 widget.Init(params); 223 widget.Init(params);
204 mus::Window* window = 224 mus::Window* window =
205 static_cast<NativeWidgetMus*>(widget.native_widget_private())->window(); 225 static_cast<NativeWidgetMus*>(widget.native_widget_private())->window();
206 EXPECT_EQ("MyWidget", window->GetName()); 226 EXPECT_EQ("MyWidget", window->GetName());
207 } 227 }
208 228
209 } // namespace 229 } // namespace
210 } // namespace views 230 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698