Commit 91d4273f authored by Eliot Courtney's avatar Eliot Courtney Committed by Commit Bot

Allow resizing for PIP windows.

Bug: b/109716842
Test: Able to free resize PIP windows with Android side patch.
Change-Id: If27051f3edc27cebc5f2e27f78daf8ea2f60f60e
Reviewed-on: https://chromium-review.googlesource.com/1134810Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Eliot Courtney <edcourtney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577796}
parent a1b22872
......@@ -80,7 +80,7 @@ std::unique_ptr<WindowResizer> CreateWindowResizer(
return window_resizer;
}
if (!window_state->IsNormalOrSnapped())
if (!window_state->IsNormalOrSnapped() && !window_state->IsPip())
return nullptr;
int bounds_change =
......@@ -93,7 +93,8 @@ std::unique_ptr<WindowResizer> CreateWindowResizer(
window->parent() ? window->parent()->id() : -1;
if (window->parent() &&
(parent_shell_window_id == kShellWindowId_DefaultContainer ||
parent_shell_window_id == kShellWindowId_PanelContainer)) {
parent_shell_window_id == kShellWindowId_PanelContainer ||
parent_shell_window_id == kShellWindowId_AlwaysOnTopContainer)) {
window_resizer.reset(WorkspaceWindowResizer::Create(
window_state, std::vector<aura::Window*>()));
} else {
......
......@@ -22,6 +22,7 @@
#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/hit_test.h"
#include "ui/display/display_layout.h"
......@@ -60,6 +61,38 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate {
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
};
// WindowState based on a given initial state. Records the last resize bounds.
class FakeWindowState : public wm::WindowState::State {
public:
explicit FakeWindowState(mojom::WindowStateType initial_state_type)
: state_type_(initial_state_type) {}
~FakeWindowState() override = default;
// WindowState::State overrides:
void OnWMEvent(wm::WindowState* window_state,
const wm::WMEvent* event) override {
if (event->IsBoundsEvent()) {
if (event->type() == wm::WM_EVENT_SET_BOUNDS) {
const auto* set_bounds_event =
static_cast<const wm::SetBoundsEvent*>(event);
last_bounds_ = set_bounds_event->requested_bounds();
}
}
}
mojom::WindowStateType GetType() const override { return state_type_; }
void AttachState(wm::WindowState* window_state,
wm::WindowState::State* previous_state) override {}
void DetachState(wm::WindowState* window_state) override {}
const gfx::Rect& last_bounds() { return last_bounds_; }
private:
mojom::WindowStateType state_type_;
gfx::Rect last_bounds_;
DISALLOW_COPY_AND_ASSIGN(FakeWindowState);
};
} // namespace
class WorkspaceWindowResizerTest : public AshTestBase {
......@@ -1847,4 +1880,26 @@ TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_BOTTOM) {
touch_resize_window_->bounds().ToString());
}
TEST_F(WorkspaceWindowResizerTest, PipCanBeResized) {
aura::Window* root_window = Shell::GetPrimaryRootWindow();
aura::Window* container =
Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer);
std::unique_ptr<aura::Window> window(
aura::test::CreateTestWindowWithId(0, container));
window->SetBounds(gfx::Rect(20, 30, 50, 60));
window->Show();
auto* fake_state = new FakeWindowState(mojom::WindowStateType::PIP);
wm::WindowState* window_state = wm::GetWindowState(window.get());
window_state->SetStateObject(
std::unique_ptr<wm::WindowState::State>(fake_state));
std::unique_ptr<WindowResizer> resizer(
CreateResizerForTest(window.get(), gfx::Point(), HTRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0);
resizer->CompleteDrag();
EXPECT_EQ("20,30 100x60", fake_state->last_bounds().ToString());
}
} // namespace ash
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