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

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 118283003: Make Widget::Show() creates active windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more ShowInactive() calls Created 6 years, 11 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/widget/widget.h ('k') | ui/views/win/hwnd_message_handler.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 DISALLOW_COPY_AND_ASSIGN(EventCountHandler); 161 DISALLOW_COPY_AND_ASSIGN(EventCountHandler);
162 }; 162 };
163 163
164 ui::WindowShowState GetWidgetShowState(const Widget* widget) { 164 ui::WindowShowState GetWidgetShowState(const Widget* widget) {
165 // Use IsMaximized/IsMinimized/IsFullScreen instead of GetWindowPlacement 165 // Use IsMaximized/IsMinimized/IsFullScreen instead of GetWindowPlacement
166 // because the former is implemented on all platforms but the latter is not. 166 // because the former is implemented on all platforms but the latter is not.
167 return widget->IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN : 167 return widget->IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN :
168 widget->IsMaximized() ? ui::SHOW_STATE_MAXIMIZED : 168 widget->IsMaximized() ? ui::SHOW_STATE_MAXIMIZED :
169 widget->IsMinimized() ? ui::SHOW_STATE_MINIMIZED : 169 widget->IsMinimized() ? ui::SHOW_STATE_MINIMIZED :
170 ui::SHOW_STATE_NORMAL; 170 widget->IsActive() ? ui::SHOW_STATE_NORMAL :
171 ui::SHOW_STATE_INACTIVE;
171 } 172 }
172 173
173 TEST_F(WidgetTest, WidgetInitParams) { 174 TEST_F(WidgetTest, WidgetInitParams) {
174 // Widgets are not transparent by default. 175 // Widgets are not transparent by default.
175 Widget::InitParams init1; 176 Widget::InitParams init1;
176 EXPECT_EQ(Widget::InitParams::INFER_OPACITY, init1.opacity); 177 EXPECT_EQ(Widget::InitParams::INFER_OPACITY, init1.opacity);
177 } 178 }
178 179
179 //////////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////////
180 // Widget::GetTopLevelWidget tests. 181 // Widget::GetTopLevelWidget tests.
(...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 reinterpret_cast<WPARAM>(win32_window), 2222 reinterpret_cast<WPARAM>(win32_window),
2222 MAKELPARAM(WM_LBUTTONDOWN, HTCLIENT)); 2223 MAKELPARAM(WM_LBUTTONDOWN, HTCLIENT));
2223 EXPECT_EQ(activate_result, MA_ACTIVATE); 2224 EXPECT_EQ(activate_result, MA_ACTIVATE);
2224 2225
2225 modal_dialog_widget->CloseNow(); 2226 modal_dialog_widget->CloseNow();
2226 top_level_widget.CloseNow(); 2227 top_level_widget.CloseNow();
2227 } 2228 }
2228 #endif 2229 #endif
2229 #endif 2230 #endif
2230 2231
2232 TEST_F(WidgetTest, ShowCreatesActiveWindow) {
2233 Widget* widget = CreateTopLevelPlatformWidget();
2234
2235 widget->Show();
2236 EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
2237
2238 widget->CloseNow();
2239 }
2240
2241 TEST_F(WidgetTest, ShowInactive) {
2242 Widget* widget = CreateTopLevelPlatformWidget();
2243
2244 widget->ShowInactive();
2245 EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_INACTIVE);
2246
2247 widget->CloseNow();
2248 }
2249
2250 TEST_F(WidgetTest, ShowInactiveAfterShow) {
2251 Widget* widget = CreateTopLevelPlatformWidget();
2252
2253 widget->Show();
2254 widget->ShowInactive();
2255 EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
2256
2257 widget->CloseNow();
2258 }
2259
2260 TEST_F(WidgetTest, ShowAfterShowInactive) {
2261 Widget* widget = CreateTopLevelPlatformWidget();
2262
2263 widget->ShowInactive();
2264 widget->Show();
2265 EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
2266
2267 widget->CloseNow();
2268 }
2269
2231 } // namespace test 2270 } // namespace test
2232 } // namespace views 2271 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget.h ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698