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

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2714763002: Change FocusSynchronizer to maintain active focus client and window. (Closed)
Patch Set: test Created 3 years, 8 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/aura/mus/window_tree_client.h ('k') | ui/aura/test/aura_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "mojo/public/cpp/bindings/map.h" 14 #include "mojo/public/cpp/bindings/map.h"
15 #include "services/ui/public/cpp/property_type_converters.h" 15 #include "services/ui/public/cpp/property_type_converters.h"
16 #include "services/ui/public/interfaces/window_manager.mojom.h" 16 #include "services/ui/public/interfaces/window_manager.mojom.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/aura/client/aura_constants.h" 18 #include "ui/aura/client/aura_constants.h"
19 #include "ui/aura/client/capture_client.h" 19 #include "ui/aura/client/capture_client.h"
20 #include "ui/aura/client/capture_client_observer.h" 20 #include "ui/aura/client/capture_client_observer.h"
21 #include "ui/aura/client/default_capture_client.h" 21 #include "ui/aura/client/default_capture_client.h"
22 #include "ui/aura/client/focus_client.h" 22 #include "ui/aura/client/focus_client.h"
23 #include "ui/aura/client/transient_window_client.h" 23 #include "ui/aura/client/transient_window_client.h"
24 #include "ui/aura/mus/capture_synchronizer.h" 24 #include "ui/aura/mus/capture_synchronizer.h"
25 #include "ui/aura/mus/focus_synchronizer.h"
25 #include "ui/aura/mus/property_converter.h" 26 #include "ui/aura/mus/property_converter.h"
26 #include "ui/aura/mus/window_mus.h" 27 #include "ui/aura/mus/window_mus.h"
27 #include "ui/aura/mus/window_tree_client_delegate.h" 28 #include "ui/aura/mus/window_tree_client_delegate.h"
28 #include "ui/aura/mus/window_tree_client_observer.h" 29 #include "ui/aura/mus/window_tree_client_observer.h"
29 #include "ui/aura/mus/window_tree_host_mus.h" 30 #include "ui/aura/mus/window_tree_host_mus.h"
30 #include "ui/aura/test/aura_mus_test_base.h" 31 #include "ui/aura/test/aura_mus_test_base.h"
31 #include "ui/aura/test/mus/test_window_tree.h" 32 #include "ui/aura/test/mus/test_window_tree.h"
32 #include "ui/aura/test/mus/window_tree_client_private.h" 33 #include "ui/aura/test/mus/window_tree_client_private.h"
33 #include "ui/aura/test/test_window_delegate.h" 34 #include "ui/aura/test/test_window_delegate.h"
34 #include "ui/aura/test/test_window_targeter.h" 35 #include "ui/aura/test/test_window_targeter.h"
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 ASSERT_TRUE(last_event); 1025 ASSERT_TRUE(last_event);
1025 EXPECT_EQ(ui::ET_POINTER_DOWN, last_event->type()); 1026 EXPECT_EQ(ui::ET_POINTER_DOWN, last_event->type());
1026 EXPECT_EQ(ui::EF_CONTROL_DOWN, last_event->flags()); 1027 EXPECT_EQ(ui::EF_CONTROL_DOWN, last_event->flags());
1027 } 1028 }
1028 1029
1029 // Verifies focus is reverted if the server replied that the change failed. 1030 // Verifies focus is reverted if the server replied that the change failed.
1030 TEST_F(WindowTreeClientWmTest, SetFocusFailed) { 1031 TEST_F(WindowTreeClientWmTest, SetFocusFailed) {
1031 Window child(nullptr); 1032 Window child(nullptr);
1032 child.Init(ui::LAYER_NOT_DRAWN); 1033 child.Init(ui::LAYER_NOT_DRAWN);
1033 root_window()->AddChild(&child); 1034 root_window()->AddChild(&child);
1035 // AuraTestHelper::SetUp sets the active focus client and focus client root,
1036 // root_window() is assumed to have focus until we actually focus on a
1037 // certain window.
1038 EXPECT_EQ(WindowMus::Get(root_window()),
1039 window_tree_client_impl()->focus_synchronizer()->focused_window());
1034 child.Focus(); 1040 child.Focus();
1035 ASSERT_TRUE(child.HasFocus()); 1041 ASSERT_TRUE(child.HasFocus());
1042 EXPECT_EQ(&child, client::GetFocusClient(&child)->GetFocusedWindow());
1036 ASSERT_TRUE( 1043 ASSERT_TRUE(
1037 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::FOCUS, false)); 1044 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::FOCUS, false));
1038 EXPECT_EQ(nullptr, client::GetFocusClient(&child)->GetFocusedWindow()); 1045 // If the change failed, we fall back to the revert_value which is the
1046 // current focused_window.
1047 EXPECT_EQ(root_window(), client::GetFocusClient(&child)->GetFocusedWindow());
1039 } 1048 }
1040 1049
1041 // Simulates a focus change, and while the focus change is in flight the server 1050 // Simulates a focus change, and while the focus change is in flight the server
1042 // replies with a new focus and the original focus change fails. 1051 // replies with a new focus and the original focus change fails.
1043 TEST_F(WindowTreeClientWmTest, SetFocusFailedWithPendingChange) { 1052 TEST_F(WindowTreeClientWmTest, SetFocusFailedWithPendingChange) {
1044 Window child1(nullptr); 1053 Window child1(nullptr);
1045 child1.Init(ui::LAYER_NOT_DRAWN); 1054 child1.Init(ui::LAYER_NOT_DRAWN);
1046 root_window()->AddChild(&child1); 1055 root_window()->AddChild(&child1);
1047 Window child2(nullptr); 1056 Window child2(nullptr);
1048 child2.Init(ui::LAYER_NOT_DRAWN); 1057 child2.Init(ui::LAYER_NOT_DRAWN);
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 window_tree()->GetEventResult(event_id)); 2115 window_tree()->GetEventResult(event_id));
2107 EXPECT_TRUE(window_delegate1.got_move()); 2116 EXPECT_TRUE(window_delegate1.got_move());
2108 EXPECT_FALSE(window_delegate2.got_move()); 2117 EXPECT_FALSE(window_delegate2.got_move());
2109 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, 2118 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20,
2110 event_location_in_dip.y() + 30); 2119 event_location_in_dip.y() + 30);
2111 EXPECT_EQ(transformed_event_location_in_dip, 2120 EXPECT_EQ(transformed_event_location_in_dip,
2112 window_delegate1.last_event_location()); 2121 window_delegate1.last_event_location());
2113 } 2122 }
2114 2123
2115 } // namespace aura 2124 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/test/aura_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698