| OLD | NEW |
| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ui::SHOW_STATE_NORMAL; |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_F(WidgetTest, WidgetInitParams) { | 173 TEST_F(WidgetTest, WidgetInitParams) { |
| 174 ASSERT_FALSE(views_delegate().UseTransparentWindows()); | |
| 175 | |
| 176 // Widgets are not transparent by default. | 174 // Widgets are not transparent by default. |
| 177 Widget::InitParams init1; | 175 Widget::InitParams init1; |
| 178 EXPECT_EQ(Widget::InitParams::INFER_OPACITY, init1.opacity); | 176 EXPECT_EQ(Widget::InitParams::INFER_OPACITY, init1.opacity); |
| 179 | |
| 180 // Non-window widgets are not transparent either. | |
| 181 Widget::InitParams init2(Widget::InitParams::TYPE_MENU); | |
| 182 EXPECT_EQ(Widget::InitParams::INFER_OPACITY, init2.opacity); | |
| 183 | |
| 184 // A ViewsDelegate can set windows transparent by default. | |
| 185 views_delegate().SetUseTransparentWindows(true); | |
| 186 Widget::InitParams init3; | |
| 187 EXPECT_EQ(Widget::InitParams::TRANSLUCENT_WINDOW, init3.opacity); | |
| 188 | |
| 189 // Non-window widgets stay opaque. | |
| 190 Widget::InitParams init4(Widget::InitParams::TYPE_MENU); | |
| 191 EXPECT_EQ(Widget::InitParams::INFER_OPACITY, init4.opacity); | |
| 192 } | 177 } |
| 193 | 178 |
| 194 //////////////////////////////////////////////////////////////////////////////// | 179 //////////////////////////////////////////////////////////////////////////////// |
| 195 // Widget::GetTopLevelWidget tests. | 180 // Widget::GetTopLevelWidget tests. |
| 196 | 181 |
| 197 TEST_F(WidgetTest, GetTopLevelWidget_Native) { | 182 TEST_F(WidgetTest, GetTopLevelWidget_Native) { |
| 198 // Create a hierarchy of native widgets. | 183 // Create a hierarchy of native widgets. |
| 199 Widget* toplevel = CreateTopLevelPlatformWidget(); | 184 Widget* toplevel = CreateTopLevelPlatformWidget(); |
| 200 gfx::NativeView parent = toplevel->GetNativeView(); | 185 gfx::NativeView parent = toplevel->GetNativeView(); |
| 201 Widget* child = CreateChildPlatformWidget(parent); | 186 Widget* child = CreateChildPlatformWidget(parent); |
| (...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 EXPECT_EQ(activate_result, MA_ACTIVATE); | 2219 EXPECT_EQ(activate_result, MA_ACTIVATE); |
| 2235 | 2220 |
| 2236 modal_dialog_widget->CloseNow(); | 2221 modal_dialog_widget->CloseNow(); |
| 2237 top_level_widget.CloseNow(); | 2222 top_level_widget.CloseNow(); |
| 2238 } | 2223 } |
| 2239 #endif | 2224 #endif |
| 2240 #endif | 2225 #endif |
| 2241 | 2226 |
| 2242 } // namespace test | 2227 } // namespace test |
| 2243 } // namespace views | 2228 } // namespace views |
| OLD | NEW |