OLD | NEW |
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 "ui/wm/core/transient_window_manager.h" | 5 #include "ui/wm/core/transient_window_manager.h" |
6 | 6 |
7 #include "ui/aura/client/visibility_client.h" | 7 #include "ui/aura/client/visibility_client.h" |
8 #include "ui/aura/client/window_tree_client.h" | 8 #include "ui/aura/client/window_tree_client.h" |
9 #include "ui/aura/layout_manager.h" | 9 #include "ui/aura/layout_manager.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 virtual ~TestTransientWindowObserver() { | 29 virtual ~TestTransientWindowObserver() { |
30 } | 30 } |
31 | 31 |
32 int add_count() const { return add_count_; } | 32 int add_count() const { return add_count_; } |
33 int remove_count() const { return remove_count_; } | 33 int remove_count() const { return remove_count_; } |
34 | 34 |
35 // TransientWindowObserver overrides: | 35 // TransientWindowObserver overrides: |
36 virtual void OnTransientChildAdded(Window* window, | 36 virtual void OnTransientChildAdded(Window* window, |
37 Window* transient) OVERRIDE { | 37 Window* transient) override { |
38 add_count_++; | 38 add_count_++; |
39 } | 39 } |
40 virtual void OnTransientChildRemoved(Window* window, | 40 virtual void OnTransientChildRemoved(Window* window, |
41 Window* transient) OVERRIDE { | 41 Window* transient) override { |
42 remove_count_++; | 42 remove_count_++; |
43 } | 43 } |
44 | 44 |
45 private: | 45 private: |
46 int add_count_; | 46 int add_count_; |
47 int remove_count_; | 47 int remove_count_; |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(TestTransientWindowObserver); | 49 DISALLOW_COPY_AND_ASSIGN(TestTransientWindowObserver); |
50 }; | 50 }; |
51 | 51 |
52 class TransientWindowManagerTest : public aura::test::AuraTestBase { | 52 class TransientWindowManagerTest : public aura::test::AuraTestBase { |
53 public: | 53 public: |
54 TransientWindowManagerTest() {} | 54 TransientWindowManagerTest() {} |
55 virtual ~TransientWindowManagerTest() {} | 55 virtual ~TransientWindowManagerTest() {} |
56 | 56 |
57 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() override { |
58 AuraTestBase::SetUp(); | 58 AuraTestBase::SetUp(); |
59 wm_state_.reset(new wm::WMState); | 59 wm_state_.reset(new wm::WMState); |
60 } | 60 } |
61 | 61 |
62 virtual void TearDown() OVERRIDE { | 62 virtual void TearDown() override { |
63 wm_state_.reset(); | 63 wm_state_.reset(); |
64 AuraTestBase::TearDown(); | 64 AuraTestBase::TearDown(); |
65 } | 65 } |
66 | 66 |
67 protected: | 67 protected: |
68 // Creates a transient window that is transient to |parent|. | 68 // Creates a transient window that is transient to |parent|. |
69 Window* CreateTransientChild(int id, Window* parent) { | 69 Window* CreateTransientChild(int id, Window* parent) { |
70 Window* window = new Window(NULL); | 70 Window* window = new Window(NULL); |
71 window->set_id(id); | 71 window->set_id(id); |
72 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 72 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 // Used by NotifyDelegateAfterDeletingTransients. Adds a string to a vector when | 343 // Used by NotifyDelegateAfterDeletingTransients. Adds a string to a vector when |
344 // OnWindowDestroyed() is invoked so that destruction order can be verified. | 344 // OnWindowDestroyed() is invoked so that destruction order can be verified. |
345 class DestroyedTrackingDelegate : public aura::test::TestWindowDelegate { | 345 class DestroyedTrackingDelegate : public aura::test::TestWindowDelegate { |
346 public: | 346 public: |
347 explicit DestroyedTrackingDelegate(const std::string& name, | 347 explicit DestroyedTrackingDelegate(const std::string& name, |
348 std::vector<std::string>* results) | 348 std::vector<std::string>* results) |
349 : name_(name), | 349 : name_(name), |
350 results_(results) {} | 350 results_(results) {} |
351 | 351 |
352 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE { | 352 virtual void OnWindowDestroyed(aura::Window* window) override { |
353 results_->push_back(name_); | 353 results_->push_back(name_); |
354 } | 354 } |
355 | 355 |
356 private: | 356 private: |
357 const std::string name_; | 357 const std::string name_; |
358 std::vector<std::string>* results_; | 358 std::vector<std::string>* results_; |
359 | 359 |
360 DISALLOW_COPY_AND_ASSIGN(DestroyedTrackingDelegate); | 360 DISALLOW_COPY_AND_ASSIGN(DestroyedTrackingDelegate); |
361 }; | 361 }; |
362 | 362 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 public: | 455 public: |
456 explicit StackingMadrigalLayoutManager(Window* root_window) | 456 explicit StackingMadrigalLayoutManager(Window* root_window) |
457 : root_window_(root_window) { | 457 : root_window_(root_window) { |
458 root_window_->SetLayoutManager(this); | 458 root_window_->SetLayoutManager(this); |
459 } | 459 } |
460 virtual ~StackingMadrigalLayoutManager() { | 460 virtual ~StackingMadrigalLayoutManager() { |
461 } | 461 } |
462 | 462 |
463 private: | 463 private: |
464 // Overridden from LayoutManager: | 464 // Overridden from LayoutManager: |
465 virtual void OnWindowResized() OVERRIDE {} | 465 virtual void OnWindowResized() override {} |
466 virtual void OnWindowAddedToLayout(Window* child) OVERRIDE {} | 466 virtual void OnWindowAddedToLayout(Window* child) override {} |
467 virtual void OnWillRemoveWindowFromLayout(Window* child) OVERRIDE {} | 467 virtual void OnWillRemoveWindowFromLayout(Window* child) override {} |
468 virtual void OnWindowRemovedFromLayout(Window* child) OVERRIDE {} | 468 virtual void OnWindowRemovedFromLayout(Window* child) override {} |
469 virtual void OnChildWindowVisibilityChanged(Window* child, | 469 virtual void OnChildWindowVisibilityChanged(Window* child, |
470 bool visible) OVERRIDE { | 470 bool visible) override { |
471 Window::Windows::const_iterator it = root_window_->children().begin(); | 471 Window::Windows::const_iterator it = root_window_->children().begin(); |
472 Window* last_window = NULL; | 472 Window* last_window = NULL; |
473 for (; it != root_window_->children().end(); ++it) { | 473 for (; it != root_window_->children().end(); ++it) { |
474 if (*it == child && last_window) { | 474 if (*it == child && last_window) { |
475 if (!visible) | 475 if (!visible) |
476 root_window_->StackChildAbove(last_window, *it); | 476 root_window_->StackChildAbove(last_window, *it); |
477 else | 477 else |
478 root_window_->StackChildAbove(*it, last_window); | 478 root_window_->StackChildAbove(*it, last_window); |
479 break; | 479 break; |
480 } | 480 } |
481 last_window = *it; | 481 last_window = *it; |
482 } | 482 } |
483 } | 483 } |
484 virtual void SetChildBounds(Window* child, | 484 virtual void SetChildBounds(Window* child, |
485 const gfx::Rect& requested_bounds) OVERRIDE { | 485 const gfx::Rect& requested_bounds) override { |
486 SetChildBoundsDirect(child, requested_bounds); | 486 SetChildBoundsDirect(child, requested_bounds); |
487 } | 487 } |
488 | 488 |
489 Window* root_window_; | 489 Window* root_window_; |
490 | 490 |
491 DISALLOW_COPY_AND_ASSIGN(StackingMadrigalLayoutManager); | 491 DISALLOW_COPY_AND_ASSIGN(StackingMadrigalLayoutManager); |
492 }; | 492 }; |
493 | 493 |
494 class StackingMadrigalVisibilityClient : public aura::client::VisibilityClient { | 494 class StackingMadrigalVisibilityClient : public aura::client::VisibilityClient { |
495 public: | 495 public: |
496 explicit StackingMadrigalVisibilityClient(Window* root_window) | 496 explicit StackingMadrigalVisibilityClient(Window* root_window) |
497 : ignored_window_(NULL) { | 497 : ignored_window_(NULL) { |
498 aura::client::SetVisibilityClient(root_window, this); | 498 aura::client::SetVisibilityClient(root_window, this); |
499 } | 499 } |
500 virtual ~StackingMadrigalVisibilityClient() { | 500 virtual ~StackingMadrigalVisibilityClient() { |
501 } | 501 } |
502 | 502 |
503 void set_ignored_window(Window* ignored_window) { | 503 void set_ignored_window(Window* ignored_window) { |
504 ignored_window_ = ignored_window; | 504 ignored_window_ = ignored_window; |
505 } | 505 } |
506 | 506 |
507 private: | 507 private: |
508 // Overridden from client::VisibilityClient: | 508 // Overridden from client::VisibilityClient: |
509 virtual void UpdateLayerVisibility(Window* window, bool visible) OVERRIDE { | 509 virtual void UpdateLayerVisibility(Window* window, bool visible) override { |
510 if (!visible) { | 510 if (!visible) { |
511 if (window == ignored_window_) | 511 if (window == ignored_window_) |
512 window->layer()->set_delegate(NULL); | 512 window->layer()->set_delegate(NULL); |
513 else | 513 else |
514 window->layer()->SetVisible(visible); | 514 window->layer()->SetVisible(visible); |
515 } else { | 515 } else { |
516 window->layer()->SetVisible(visible); | 516 window->layer()->SetVisible(visible); |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 EXPECT_EQ(0, test_observer.remove_count()); | 698 EXPECT_EQ(0, test_observer.remove_count()); |
699 | 699 |
700 RemoveTransientChild(parent.get(), w1.get()); | 700 RemoveTransientChild(parent.get(), w1.get()); |
701 EXPECT_EQ(1, test_observer.add_count()); | 701 EXPECT_EQ(1, test_observer.add_count()); |
702 EXPECT_EQ(1, test_observer.remove_count()); | 702 EXPECT_EQ(1, test_observer.remove_count()); |
703 | 703 |
704 TransientWindowManager::Get(parent.get())->RemoveObserver(&test_observer); | 704 TransientWindowManager::Get(parent.get())->RemoveObserver(&test_observer); |
705 } | 705 } |
706 | 706 |
707 } // namespace wm | 707 } // namespace wm |
OLD | NEW |