| 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 "athena/wm/window_list_provider_impl.h" | 5 #include "athena/wm/window_list_provider_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
| 10 #include "athena/test/base/athena_test_base.h" | 10 #include "athena/test/base/athena_test_base.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 return output; | 58 return output; |
| 59 } | 59 } |
| 60 | 60 |
| 61 class WindowListObserver : public WindowListProviderObserver { | 61 class WindowListObserver : public WindowListProviderObserver { |
| 62 public: | 62 public: |
| 63 explicit WindowListObserver(WindowListProvider* provider) | 63 explicit WindowListObserver(WindowListProvider* provider) |
| 64 : calls_(0), window_removal_calls_(0), provider_(provider) { | 64 : calls_(0), window_removal_calls_(0), provider_(provider) { |
| 65 provider_->AddObserver(this); | 65 provider_->AddObserver(this); |
| 66 } | 66 } |
| 67 virtual ~WindowListObserver() { | 67 ~WindowListObserver() override { provider_->RemoveObserver(this); } |
| 68 provider_->RemoveObserver(this); | |
| 69 } | |
| 70 | 68 |
| 71 int calls() const { return calls_; } | 69 int calls() const { return calls_; } |
| 72 int window_removal_calls() const { return window_removal_calls_; } | 70 int window_removal_calls() const { return window_removal_calls_; } |
| 73 | 71 |
| 74 // WindowListProviderObserver: | 72 // WindowListProviderObserver: |
| 75 virtual void OnWindowStackingChanged() override { | 73 void OnWindowStackingChanged() override { calls_++; } |
| 76 calls_++; | |
| 77 } | |
| 78 | 74 |
| 79 virtual void OnWindowRemoved(aura::Window* removed_window, | 75 void OnWindowRemoved(aura::Window* removed_window, int index) override { |
| 80 int index) override { | |
| 81 window_removal_calls_++; | 76 window_removal_calls_++; |
| 82 } | 77 } |
| 83 | 78 |
| 84 private: | 79 private: |
| 85 // The number of calls to the observer. | 80 // The number of calls to the observer. |
| 86 int calls_; | 81 int calls_; |
| 87 int window_removal_calls_; | 82 int window_removal_calls_; |
| 88 | 83 |
| 89 // The associated WindowListProvider which is observed. | 84 // The associated WindowListProvider which is observed. |
| 90 WindowListProvider* provider_; | 85 WindowListProvider* provider_; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 EXPECT_FALSE(t1->IsVisible()); | 334 EXPECT_FALSE(t1->IsVisible()); |
| 340 w1->Show(); | 335 w1->Show(); |
| 341 EXPECT_TRUE(t1->IsVisible()); | 336 EXPECT_TRUE(t1->IsVisible()); |
| 342 | 337 |
| 343 // Resetting transient window won't notify the observer. | 338 // Resetting transient window won't notify the observer. |
| 344 t1.reset(); | 339 t1.reset(); |
| 345 EXPECT_EQ(0, observer->window_removal_calls()); | 340 EXPECT_EQ(0, observer->window_removal_calls()); |
| 346 } | 341 } |
| 347 | 342 |
| 348 } // namespace athena | 343 } // namespace athena |
| OLD | NEW |