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/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 Loading... | |
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 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3698 | 3704 |
3699 EXPECT_FALSE(!!IsWindow(owner_hwnd)); | 3705 EXPECT_FALSE(!!IsWindow(owner_hwnd)); |
3700 EXPECT_FALSE(!!IsWindow(owned_hwnd)); | 3706 EXPECT_FALSE(!!IsWindow(owned_hwnd)); |
3701 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); | 3707 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); |
3702 | 3708 |
3703 top_level_widget.CloseNow(); | 3709 top_level_widget.CloseNow(); |
3704 } | 3710 } |
3705 | 3711 |
3706 #endif // defined(OS_WIN) | 3712 #endif // defined(OS_WIN) |
3707 | 3713 |
3714 #if !defined(OS_CHROMEOS) | |
3715 // Test to ensure that the transparency state of the native window maches | |
3716 // what returns ShouldWindowContentsBeTransparent(). On Linux it also checks | |
3717 // that it returns true when --enable-transparent-visuals is passed. | |
3718 TEST_F(WidgetTest, Transparency_DesktopWidget) { | |
3719 #if defined(USE_X11) | |
3720 // On Linux, transparent visuals is currently not activated by default. | |
3721 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
3722 command_line->AppendSwitch(switches::kEnableTransparentVisuals); | |
3723 | |
3724 int depth = 0; | |
3725 ui::ChooseVisualForWindow(NULL, &depth); | |
3726 EXPECT_EQ(depth, 32); | |
3727 #endif | |
3728 | |
3729 Widget::InitParams init_params = | |
3730 CreateParams(Widget::InitParams::TYPE_WINDOW); | |
3731 init_params.show_state = ui::SHOW_STATE_NORMAL; | |
3732 init_params.bounds = gfx::Rect(0, 0, 500, 500); | |
3733 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
3734 Widget widget; | |
3735 init_params.native_widget = | |
3736 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); | |
3737 widget.Init(init_params); | |
3738 | |
3739 EXPECT_EQ(IsNativeWindowTransparent(widget.GetNativeWindow()), | |
3740 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
| |
3741 | |
3742 #if defined(USE_X11) | |
3743 EXPECT_TRUE(widget.ShouldWindowContentsBeTransparent()); | |
3744 #endif | |
3745 } | |
3746 #endif // !defined(OS_CHROMEOS) | |
3747 | |
3708 } // namespace test | 3748 } // namespace test |
3709 } // namespace views | 3749 } // namespace views |
OLD | NEW |