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

Unified Diff: ui/views/widget/widget_unittest.cc

Issue 1998653002: Make DesktopWindowTreeHostX11::ShouldWindowContentsBeTransparent() relies on argb visual flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove TODO/CHECK since Win10 bots can run tests with AeroGlass enabled Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget_unittest.cc
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index f90572ca2ed9cd6939b1b186a03034646225a64b..4a2103889048cbf4980280db5d6689c3b898e485 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -7,6 +7,7 @@
#include <set>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -47,6 +48,11 @@
#include "base/mac/mac_util.h"
#endif
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
+#include "ui/base/x/x11_util_internal.h" // nogncheck
+#include "ui/gfx/x/x11_switches.h" // nogncheck
+#endif
+
namespace views {
namespace test {
@@ -3723,5 +3729,68 @@ TEST_F(WidgetTest, WindowModalOwnerDestroyedEnabledTest) {
#endif // defined(OS_WIN)
+#if !defined(OS_CHROMEOS)
+
+namespace {
+
+void InitializeWidgetForOpacity(
+ Widget& widget,
+ Widget::InitParams init_params,
+ const Widget::InitParams::WindowOpacity opacity) {
+#if defined(USE_X11)
+ // On Linux, transparent visuals is currently not activated by default.
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->AppendSwitch(switches::kEnableTransparentVisuals);
+
+ int depth = 0;
+ ui::ChooseVisualForWindow(NULL, &depth);
+ EXPECT_EQ(depth, 32);
+#endif
+
+ init_params.opacity = opacity;
+ init_params.show_state = ui::SHOW_STATE_NORMAL;
+ init_params.bounds = gfx::Rect(0, 0, 500, 500);
+ init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ init_params.native_widget =
+ CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
+ widget.Init(init_params);
+
+#if defined(USE_X11)
+ EXPECT_TRUE(widget.IsTranslucentWindowOpacitySupported());
+#endif
+}
+
+} // namespace
+
+// Test opacity when compositing is enabled.
+TEST_F(WidgetTest, Transparency_DesktopWidgetInferOpacity) {
+ Widget widget;
+ InitializeWidgetForOpacity(widget,
+ CreateParams(Widget::InitParams::TYPE_WINDOW),
+ Widget::InitParams::INFER_OPACITY);
+ EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()),
+ widget.ShouldWindowContentsBeTransparent());
+}
+
+TEST_F(WidgetTest, Transparency_DesktopWidgetOpaque) {
+ Widget widget;
+ InitializeWidgetForOpacity(widget,
+ CreateParams(Widget::InitParams::TYPE_WINDOW),
+ Widget::InitParams::OPAQUE_WINDOW);
+ EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()),
+ widget.ShouldWindowContentsBeTransparent());
+}
+
+TEST_F(WidgetTest, Transparency_DesktopWidgetTranslucent) {
+ Widget widget;
+ InitializeWidgetForOpacity(widget,
+ CreateParams(Widget::InitParams::TYPE_WINDOW),
+ Widget::InitParams::TRANSLUCENT_WINDOW);
+ EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()),
+ widget.ShouldWindowContentsBeTransparent());
+}
+
+#endif // !defined(OS_CHROMEOS)
+
} // namespace test
} // namespace views
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698