Index: ui/views/widget/widget_unittest.cc |
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc |
index 8761f7f5cc83857e0164d4f81eb654e02b4c555d..2ff3fdf3a20bd00aec5c0db0c8d9d1c6e0f7789d 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 { |
@@ -3705,5 +3711,39 @@ TEST_F(WidgetTest, WindowModalOwnerDestroyedEnabledTest) { |
#endif // defined(OS_WIN) |
+#if !defined(OS_CHROMEOS) |
+// Test to ensure that the transparency state of the native window maches |
+// what returns ShouldWindowContentsBeTransparent(). On Linux it also checks |
+// that it returns true when --enable-transparent-visuals is passed. |
+TEST_F(WidgetTest, Transparency_DesktopWidget) { |
+#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 |
+ |
+ Widget::InitParams init_params = |
+ CreateParams(Widget::InitParams::TYPE_WINDOW); |
+ 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; |
+ Widget widget; |
+ init_params.native_widget = |
+ CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); |
+ widget.Init(init_params); |
+ |
+ EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()), |
+ widget.ShouldWindowContentsBeTransparent()); |
sadrul
2016/06/14 15:45:31
You should need to at least set Widget::InitParams
Julien Isorce Samsung
2016/06/14 16:02:40
Yes you are right. Somehow the test still succeeds
|
+ |
+#if defined(USE_X11) |
+ EXPECT_TRUE(widget.ShouldWindowContentsBeTransparent()); |
+#endif |
+} |
+#endif // !defined(OS_CHROMEOS) |
+ |
} // namespace test |
} // namespace views |