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

Side by Side Diff: ash/wm/window_state_unittest.cc

Issue 1474993003: Ensure View invalidates Widget::root_layers_ when LayerOwner::RecreateLayer is invoked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ordering is hard Created 5 years 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 | « no previous file | ui/compositor/layer_owner.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/wm/window_state.h" 5 #include "ash/wm/window_state.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "ash/wm/wm_event.h" 11 #include "ash/wm/wm_event.h"
12 #include "ui/aura/client/aura_constants.h" 12 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/test/test_window_delegate.h" 13 #include "ui/aura/test/test_window_delegate.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/views/widget/widget.h"
15 16
16 namespace ash { 17 namespace ash {
17 namespace wm { 18 namespace wm {
18 namespace { 19 namespace {
19 20
20 class AlwaysMaximizeTestState : public WindowState::State { 21 class AlwaysMaximizeTestState : public WindowState::State {
21 public: 22 public:
22 explicit AlwaysMaximizeTestState(WindowStateType initial_state_type) 23 explicit AlwaysMaximizeTestState(WindowStateType initial_state_type)
23 : state_type_(initial_state_type) {} 24 : state_type_(initial_state_type) {}
24 ~AlwaysMaximizeTestState() override {} 25 ~AlwaysMaximizeTestState() override {}
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 331
331 window_state->Restore(); 332 window_state->Restore();
332 EXPECT_FALSE(window_state->IsMaximized()); 333 EXPECT_FALSE(window_state->IsMaximized());
333 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); 334 EXPECT_NE(work_area.ToString(), window->bounds().ToString());
334 EXPECT_TRUE(work_area.Contains(window->bounds())); 335 EXPECT_TRUE(work_area.Contains(window->bounds()));
335 } 336 }
336 337
337 // TODO(skuhne): Add more unit test to verify the correctness for the restore 338 // TODO(skuhne): Add more unit test to verify the correctness for the restore
338 // operation. 339 // operation.
339 340
341 // Tests for correct ownership of window sublayers during crossfade transitions.
342 TEST_F(WindowStateTest, RecreateLayersDuringCrossfade) {
sky 2015/11/30 16:52:09 This test is ok, but you're relying on maximize re
tapted 2015/12/01 04:34:43 I did this in Patchset 4, but it made the connecti
343 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
344 nullptr, CurrentContext(), gfx::Rect(100, 100, 100, 100));
345
346 views::View* view = new views::View;
347 view->SetBounds(20, 20, 20, 20);
348 widget->GetContentsView()->AddChildView(view);
349 widget->Show();
350
351 EXPECT_EQ(0u, widget->GetRootLayers().size());
352 view->SetPaintToLayer(true);
353 EXPECT_EQ(1u, widget->GetRootLayers().size());
354 ui::Layer* old_layer = widget->GetRootLayers()[0];
355
356 // On Ash, Maximize will trigger WindowState::SetBoundsDirectCrossFade() to
357 // start a crossfade animation after invoking ::wm::RecreateLayers().
358 widget->Maximize();
359
360 EXPECT_EQ(1u, widget->GetRootLayers().size());
361
362 // The layer should be different, since the old layer is in the crossfade.
363 EXPECT_NE(old_layer, widget->GetRootLayers()[0]);
364
365 widget->CloseNow();
366 }
367
340 } // namespace wm 368 } // namespace wm
341 } // namespace ash 369 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/layer_owner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698