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 <memory> | 6 #include <memory> |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/environment.h" | 10 #include "base/command_line.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "ui/base/hit_test.h" | 17 #include "ui/base/hit_test.h" |
18 #include "ui/compositor/layer_animation_observer.h" | 18 #include "ui/compositor/layer_animation_observer.h" |
19 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 19 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
20 #include "ui/compositor/scoped_layer_animation_settings.h" | 20 #include "ui/compositor/scoped_layer_animation_settings.h" |
(...skipping 3712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3733 | 3733 |
3734 #if !defined(OS_CHROMEOS) | 3734 #if !defined(OS_CHROMEOS) |
3735 | 3735 |
3736 namespace { | 3736 namespace { |
3737 | 3737 |
3738 void InitializeWidgetForOpacity( | 3738 void InitializeWidgetForOpacity( |
3739 Widget& widget, | 3739 Widget& widget, |
3740 Widget::InitParams init_params, | 3740 Widget::InitParams init_params, |
3741 const Widget::InitParams::WindowOpacity opacity) { | 3741 const Widget::InitParams::WindowOpacity opacity) { |
3742 #if defined(USE_X11) | 3742 #if defined(USE_X11) |
3743 // testing/xvfb.py runs xvfb and xcompmgr. | 3743 // On Linux, transparent visuals is currently not activated by default. |
3744 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 3744 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
3745 bool has_compositing_manager = env->HasVar("_CHROMIUM_INSIDE_XVFB"); | 3745 command_line->AppendSwitch(switches::kEnableTransparentVisuals); |
| 3746 |
3746 int depth = 0; | 3747 int depth = 0; |
3747 ui::ChooseVisualForWindow(has_compositing_manager, NULL, &depth); | 3748 ui::ChooseVisualForWindow(NULL, &depth); |
3748 | 3749 EXPECT_EQ(depth, 32); |
3749 if (has_compositing_manager) | |
3750 EXPECT_EQ(depth, 32); | |
3751 #endif | 3750 #endif |
3752 | 3751 |
3753 init_params.opacity = opacity; | 3752 init_params.opacity = opacity; |
3754 init_params.show_state = ui::SHOW_STATE_NORMAL; | 3753 init_params.show_state = ui::SHOW_STATE_NORMAL; |
3755 init_params.bounds = gfx::Rect(0, 0, 500, 500); | 3754 init_params.bounds = gfx::Rect(0, 0, 500, 500); |
3756 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 3755 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
3757 init_params.native_widget = | 3756 init_params.native_widget = |
3758 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); | 3757 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); |
3759 widget.Init(init_params); | 3758 widget.Init(init_params); |
3760 | 3759 |
3761 #if defined(USE_X11) | 3760 #if defined(USE_X11) |
3762 if (has_compositing_manager) | 3761 EXPECT_TRUE(widget.IsTranslucentWindowOpacitySupported()); |
3763 EXPECT_TRUE(widget.IsTranslucentWindowOpacitySupported()); | |
3764 #endif | 3762 #endif |
3765 } | 3763 } |
3766 | 3764 |
3767 } // namespace | 3765 } // namespace |
3768 | 3766 |
3769 // Test opacity when compositing is enabled. | 3767 // Test opacity when compositing is enabled. |
3770 TEST_F(WidgetTest, Transparency_DesktopWidgetInferOpacity) { | 3768 TEST_F(WidgetTest, Transparency_DesktopWidgetInferOpacity) { |
3771 Widget widget; | 3769 Widget widget; |
3772 InitializeWidgetForOpacity(widget, | 3770 InitializeWidgetForOpacity(widget, |
3773 CreateParams(Widget::InitParams::TYPE_WINDOW), | 3771 CreateParams(Widget::InitParams::TYPE_WINDOW), |
(...skipping 25 matching lines...) Expand all Loading... |
3799 CreateParams(Widget::InitParams::TYPE_WINDOW), | 3797 CreateParams(Widget::InitParams::TYPE_WINDOW), |
3800 Widget::InitParams::TRANSLUCENT_WINDOW); | 3798 Widget::InitParams::TRANSLUCENT_WINDOW); |
3801 EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()), | 3799 EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()), |
3802 widget.ShouldWindowContentsBeTransparent()); | 3800 widget.ShouldWindowContentsBeTransparent()); |
3803 } | 3801 } |
3804 | 3802 |
3805 #endif // !defined(OS_CHROMEOS) | 3803 #endif // !defined(OS_CHROMEOS) |
3806 | 3804 |
3807 } // namespace test | 3805 } // namespace test |
3808 } // namespace views | 3806 } // namespace views |
OLD | NEW |