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

Side by Side 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 unified diff | 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 »
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 <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/command_line.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/base/hit_test.h" 17 #include "ui/base/hit_test.h"
17 #include "ui/compositor/layer_animation_observer.h" 18 #include "ui/compositor/layer_animation_observer.h"
18 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 19 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h" 20 #include "ui/compositor/scoped_layer_animation_settings.h"
(...skipping 20 matching lines...) Expand all
40 #include "ui/aura/window_tree_host.h" 41 #include "ui/aura/window_tree_host.h"
41 #include "ui/base/view_prop.h" 42 #include "ui/base/view_prop.h"
42 #include "ui/base/win/window_event_target.h" 43 #include "ui/base/win/window_event_target.h"
43 #include "ui/views/win/hwnd_util.h" 44 #include "ui/views/win/hwnd_util.h"
44 #endif 45 #endif
45 46
46 #if defined(OS_MACOSX) 47 #if defined(OS_MACOSX)
47 #include "base/mac/mac_util.h" 48 #include "base/mac/mac_util.h"
48 #endif 49 #endif
49 50
51 #if defined(USE_X11) && !defined(OS_CHROMEOS)
52 #include "ui/base/x/x11_util_internal.h" // nogncheck
53 #include "ui/gfx/x/x11_switches.h" // nogncheck
54 #endif
55
50 namespace views { 56 namespace views {
51 namespace test { 57 namespace test {
52 58
53 namespace { 59 namespace {
54 60
55 // TODO(tdanderson): This utility function is used in different unittest 61 // TODO(tdanderson): This utility function is used in different unittest
56 // files. Move to a common location to avoid 62 // files. Move to a common location to avoid
57 // repeated code. 63 // repeated code.
58 gfx::Point ConvertPointFromWidgetToView(View* view, const gfx::Point& p) { 64 gfx::Point ConvertPointFromWidgetToView(View* view, const gfx::Point& p) {
59 gfx::Point tmp(p); 65 gfx::Point tmp(p);
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after
3716 3722
3717 EXPECT_FALSE(!!IsWindow(owner_hwnd)); 3723 EXPECT_FALSE(!!IsWindow(owner_hwnd));
3718 EXPECT_FALSE(!!IsWindow(owned_hwnd)); 3724 EXPECT_FALSE(!!IsWindow(owned_hwnd));
3719 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); 3725 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd));
3720 3726
3721 top_level_widget.CloseNow(); 3727 top_level_widget.CloseNow();
3722 } 3728 }
3723 3729
3724 #endif // defined(OS_WIN) 3730 #endif // defined(OS_WIN)
3725 3731
3732 #if !defined(OS_CHROMEOS)
3733
3734 namespace {
3735
3736 void InitializeWidgetForOpacity(
3737 Widget& widget,
3738 Widget::InitParams init_params,
3739 const Widget::InitParams::WindowOpacity opacity) {
3740 #if defined(USE_X11)
3741 // On Linux, transparent visuals is currently not activated by default.
3742 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
3743 command_line->AppendSwitch(switches::kEnableTransparentVisuals);
3744
3745 int depth = 0;
3746 ui::ChooseVisualForWindow(NULL, &depth);
3747 EXPECT_EQ(depth, 32);
3748 #endif
3749
3750 init_params.opacity = opacity;
3751 init_params.show_state = ui::SHOW_STATE_NORMAL;
3752 init_params.bounds = gfx::Rect(0, 0, 500, 500);
3753 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
3754 init_params.native_widget =
3755 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
3756 widget.Init(init_params);
3757
3758 #if defined(USE_X11)
3759 EXPECT_TRUE(widget.IsTranslucentWindowOpacitySupported());
3760 #endif
3761 }
3762
3763 } // namespace
3764
3765 // Test opacity when compositing is enabled.
3766 TEST_F(WidgetTest, Transparency_DesktopWidgetInferOpacity) {
3767 Widget widget;
3768 InitializeWidgetForOpacity(widget,
3769 CreateParams(Widget::InitParams::TYPE_WINDOW),
3770 Widget::InitParams::INFER_OPACITY);
3771 EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()),
3772 widget.ShouldWindowContentsBeTransparent());
3773 }
3774
3775 TEST_F(WidgetTest, Transparency_DesktopWidgetOpaque) {
3776 Widget widget;
3777 InitializeWidgetForOpacity(widget,
3778 CreateParams(Widget::InitParams::TYPE_WINDOW),
3779 Widget::InitParams::OPAQUE_WINDOW);
3780 EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()),
3781 widget.ShouldWindowContentsBeTransparent());
3782 }
3783
3784 TEST_F(WidgetTest, Transparency_DesktopWidgetTranslucent) {
3785 Widget widget;
3786 InitializeWidgetForOpacity(widget,
3787 CreateParams(Widget::InitParams::TYPE_WINDOW),
3788 Widget::InitParams::TRANSLUCENT_WINDOW);
3789 EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()),
3790 widget.ShouldWindowContentsBeTransparent());
3791 }
3792
3793 #endif // !defined(OS_CHROMEOS)
3794
3726 } // namespace test 3795 } // namespace test
3727 } // namespace views 3796 } // namespace views
OLDNEW
« 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