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

Side by Side Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 23702017: Ensure that the AURA focused window is set correctly when the window is activated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_root_window_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')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/basictypes.h"
6 #include "ui/gfx/native_widget_types.h"
7 #include "ui/views/widget/widget.h"
8
9 #if defined(USE_AURA)
10 #include "ui/aura/client/activation_client.h"
11 #include "ui/aura/root_window.h"
12 #include "ui/views/test/views_test_base.h"
13 #if !defined(OS_CHROMEOS)
14 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
15 #endif
16 #endif
17
18 namespace views {
19
20 #if defined(OS_WIN) && defined(USE_AURA)
21 // Tests whether activation and focus change works correctly in Windows AURA.
22 // We test the following:-
23 // 1. If the active aura window is correctly set when a top level widget is
24 // created.
25 // 2. If the active aura window in widget 1 created above, is set to NULL when
26 // another top level widget is created and focused.
27 // 3. On focusing the native platform window for widget 1, the active aura
28 // window for widget 1 should be set and that for widget 2 should reset.
29 // TODO(ananta)
30 // Discuss with erg on how to write this test for linux x11 aura.
31 TEST_F(ViewsTestBase, DesktopNativeWidgetAuraActivationAndFocusTest) {
32 // Create widget 1 and expect the active window to be its window.
33 View* contents_view1 = new View;
34 contents_view1->set_focusable(true);
35 Widget widget1;
36 Widget::InitParams init_params =
37 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
38 init_params.bounds = gfx::Rect(0, 0, 200, 200);
39 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
40 init_params.native_widget = new DesktopNativeWidgetAura(&widget1);
41 widget1.Init(init_params);
42 widget1.SetContentsView(contents_view1);
43 widget1.Show();
44 aura::RootWindow* root_window1= widget1.GetNativeView()->GetRootWindow();
45 contents_view1->RequestFocus();
46
47 EXPECT_TRUE(root_window1 != NULL);
48 aura::client::ActivationClient* activation_client1 =
49 aura::client::GetActivationClient(root_window1);
50 EXPECT_TRUE(activation_client1 != NULL);
51 EXPECT_EQ(activation_client1->GetActiveWindow(), widget1.GetNativeView());
52
53 // Create widget 2 and expect the active window to be its window.
54 View* contents_view2 = new View;
55 Widget widget2;
56 Widget::InitParams init_params2 =
57 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
58 init_params2.bounds = gfx::Rect(0, 0, 200, 200);
59 init_params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
60 init_params2.native_widget = new DesktopNativeWidgetAura(&widget2);
61 widget2.Init(init_params2);
62 widget2.SetContentsView(contents_view2);
63 widget2.Show();
64 aura::RootWindow* root_window2 = widget2.GetNativeView()->GetRootWindow();
65 contents_view2->RequestFocus();
66 ::SetActiveWindow(root_window2->GetAcceleratedWidget());
67
68 aura::client::ActivationClient* activation_client2 =
69 aura::client::GetActivationClient(root_window2);
70 EXPECT_TRUE(activation_client2 != NULL);
71 EXPECT_EQ(activation_client2->GetActiveWindow(), widget2.GetNativeView());
72 EXPECT_EQ(activation_client1->GetActiveWindow(),
73 reinterpret_cast<aura::Window*>(NULL));
74
75 // Now set focus back to widget 1 and expect the active window to be its
76 // window.
77 contents_view1->RequestFocus();
78 ::SetActiveWindow(root_window1->GetAcceleratedWidget());
79 EXPECT_EQ(activation_client2->GetActiveWindow(),
80 reinterpret_cast<aura::Window*>(NULL));
81 EXPECT_EQ(activation_client1->GetActiveWindow(), widget1.GetNativeView());
82 }
83 #endif
84
85 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698