Commit 25ab6c00 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: makes changes to can activate go to server

This is necessary as it's not uncommon to have code like this:

  SetCanActivate(true);
  widget->Activate();
  SetCanActivate(false);

BUG=928939
TEST=none

Change-Id: I52c2d79cd7aec2fe5ab13f8ae7821227f1a0214e
Reviewed-on: https://chromium-review.googlesource.com/c/1457117
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629866}
parent dde2605c
...@@ -332,7 +332,10 @@ void TestWindowTree::SetFocus(uint32_t change_id, ws::Id window_id) { ...@@ -332,7 +332,10 @@ void TestWindowTree::SetFocus(uint32_t change_id, ws::Id window_id) {
OnChangeReceived(change_id, WindowTreeChangeType::FOCUS); OnChangeReceived(change_id, WindowTreeChangeType::FOCUS);
} }
void TestWindowTree::SetCanFocus(ws::Id window_id, bool can_focus) {} void TestWindowTree::SetCanFocus(ws::Id window_id, bool can_focus) {
++can_focus_count_;
last_can_focus_ = can_focus;
}
void TestWindowTree::SetEventTargetingPolicy( void TestWindowTree::SetEventTargetingPolicy(
ws::Id window_id, ws::Id window_id,
......
...@@ -146,6 +146,13 @@ class TestWindowTree : public ws::mojom::WindowTree { ...@@ -146,6 +146,13 @@ class TestWindowTree : public ws::mojom::WindowTree {
return value; return value;
} }
bool last_can_focus() const { return last_can_focus_; }
size_t get_and_clear_can_focus_count() {
const int value = can_focus_count_;
can_focus_count_ = 0u;
return value;
}
int last_move_hit_test() const { return last_move_hit_test_; } int last_move_hit_test() const { return last_move_hit_test_; }
size_t get_and_clear_window_resize_shadow_count() { size_t get_and_clear_window_resize_shadow_count() {
...@@ -336,6 +343,8 @@ class TestWindowTree : public ws::mojom::WindowTree { ...@@ -336,6 +343,8 @@ class TestWindowTree : public ws::mojom::WindowTree {
ws::Id last_transfer_new_ = 0u; ws::Id last_transfer_new_ = 0u;
bool last_transfer_should_cancel_ = false; bool last_transfer_should_cancel_ = false;
bool last_accepts_drops_ = false; bool last_accepts_drops_ = false;
size_t can_focus_count_ = 0u;
bool last_can_focus_ = false;
size_t accepts_drops_count_ = 0u; size_t accepts_drops_count_ = 0u;
......
...@@ -935,7 +935,8 @@ void DesktopWindowTreeHostMus::SetBoundsInDIP(const gfx::Rect& bounds_in_dip) { ...@@ -935,7 +935,8 @@ void DesktopWindowTreeHostMus::SetBoundsInDIP(const gfx::Rect& bounds_in_dip) {
} }
void DesktopWindowTreeHostMus::OnCanActivateChanged() { void DesktopWindowTreeHostMus::OnCanActivateChanged() {
// TODO(crbug.com/928939): call to WindowTreeClient::SetCanFocus() MusClient::Get()->window_tree_client()->SetCanFocus(
window(), native_widget_delegate_->CanActivate());
} }
void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() { void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() {
......
...@@ -1075,6 +1075,30 @@ TEST_F(DesktopWindowTreeHostMusTest, MinMaxSize) { ...@@ -1075,6 +1075,30 @@ TEST_F(DesktopWindowTreeHostMusTest, MinMaxSize) {
EXPECT_FALSE(window->GetProperty(aura::client::kMaximumSize)); EXPECT_FALSE(window->GetProperty(aura::client::kMaximumSize));
} }
TEST_F(DesktopWindowTreeHostMusTest, SetCanFocus) {
auto* delegate = new WidgetDelegateView;
std::unique_ptr<Widget> widget = CreateWidget(delegate);
// Swap the WindowTree implementation to verify SetCanFocus() is called when
// the active state changes.
aura::TestWindowTree test_window_tree;
aura::WindowTreeClientTestApi window_tree_client_private(
MusClient::Get()->window_tree_client());
ws::mojom::WindowTree* old_tree =
window_tree_client_private.SwapTree(&test_window_tree);
delegate->SetCanActivate(false);
EXPECT_FALSE(delegate->CanActivate());
EXPECT_FALSE(test_window_tree.last_can_focus());
EXPECT_EQ(1u, test_window_tree.get_and_clear_can_focus_count());
delegate->SetCanActivate(true);
EXPECT_TRUE(delegate->CanActivate());
EXPECT_TRUE(test_window_tree.last_can_focus());
EXPECT_EQ(1u, test_window_tree.get_and_clear_can_focus_count());
window_tree_client_private.SwapTree(old_tree);
}
// DesktopWindowTreeHostMusTest with --force-device-scale-factor=1.25. // DesktopWindowTreeHostMusTest with --force-device-scale-factor=1.25.
class DesktopWindowTreeHostMusTestFractionalDPI class DesktopWindowTreeHostMusTestFractionalDPI
: public DesktopWindowTreeHostMusTest { : public DesktopWindowTreeHostMusTest {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment