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

Unified Diff: ash/wm/drag_window_resizer_unittest.cc

Issue 1992853002: Create a LayerDelegate for recreated layers to draw when their content is invalidated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/drag_window_controller.cc ('k') | chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/drag_window_resizer_unittest.cc
diff --git a/ash/wm/drag_window_resizer_unittest.cc b/ash/wm/drag_window_resizer_unittest.cc
index c3e689a2d2e8e23ba64be621ee0937b96c274bab..9c2adccd11b4c3d10e2a8f75d902ea6d907af327 100644
--- a/ash/wm/drag_window_resizer_unittest.cc
+++ b/ash/wm/drag_window_resizer_unittest.cc
@@ -24,6 +24,7 @@
#include "ui/aura/test/test_window_delegate.h"
#include "ui/base/hit_test.h"
#include "ui/base/ui_base_types.h"
+#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/display/manager/display_layout.h"
#include "ui/display/manager/display_layout_builder.h"
@@ -36,6 +37,30 @@ namespace {
const int kRootHeight = 600;
+// Used to test if the OnPaintLayer is called by DragWindowLayerDelegate.
+class TestLayerDelegate : public ui::LayerDelegate {
+ public:
+ TestLayerDelegate() = default;
+ ~TestLayerDelegate() override = default;
+
+ int paint_count() const { return paint_count_; }
+
+ private:
+ // Paint content for the layer to the specified context.
+ void OnPaintLayer(const ui::PaintContext& context) override {
+ paint_count_++;
+ }
+ void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {}
+ void OnDeviceScaleFactorChanged(float device_scale_factor) override {}
+ base::Closure PrepareForLayerBoundsChange() override {
+ return base::Closure();
+ }
+
+ int paint_count_ = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate);
+};
+
} // namespace
class DragWindowResizerTest : public test::AshTestBase {
@@ -345,6 +370,8 @@ TEST_F(DragWindowResizerTest, DragWindowController) {
aura::Window::Windows root_windows = Shell::GetAllRootWindows();
ASSERT_EQ(2U, root_windows.size());
+ TestLayerDelegate delegate;
+ window_->layer()->set_delegate(&delegate);
window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
display::Screen::GetScreen()->GetPrimaryDisplay());
EXPECT_EQ(root_windows[0], window_->GetRootWindow());
@@ -379,6 +406,16 @@ TEST_F(DragWindowResizerTest, DragWindowController) {
EXPECT_FALSE(layers.empty());
EXPECT_EQ(controller->GetDragLayerOwnerForTest(0)->root(), layers.back());
+ // The paint request on a drag window should reach the original delegate.
+ controller->RequestLayerPaintForTest();
+ EXPECT_EQ(1, delegate.paint_count());
+
+ // Invalidating the delegate on the original layer should prevent
+ // calling the OnPaintLayer on the original delegate from new delegate.
+ window_->layer()->set_delegate(nullptr);
+ controller->RequestLayerPaintForTest();
+ EXPECT_EQ(1, delegate.paint_count());
+
// |window_| should be opaque since the pointer is still on the primary
// root window. The drag window should be semi-transparent.
EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
« no previous file with comments | « ash/wm/drag_window_controller.cc ('k') | chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698