| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "ui/events/event_utils.h" | 38 #include "ui/events/event_utils.h" |
| 39 #include "ui/events/gesture_detection/gesture_configuration.h" | 39 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 40 #include "ui/events/keycodes/keyboard_codes.h" | 40 #include "ui/events/keycodes/keyboard_codes.h" |
| 41 #include "ui/events/test/event_generator.h" | 41 #include "ui/events/test/event_generator.h" |
| 42 #include "ui/gfx/canvas.h" | 42 #include "ui/gfx/canvas.h" |
| 43 #include "ui/gfx/screen.h" | 43 #include "ui/gfx/screen.h" |
| 44 #include "ui/gfx/skia_util.h" | 44 #include "ui/gfx/skia_util.h" |
| 45 #include "ui/gfx/vector2d.h" | 45 #include "ui/gfx/vector2d.h" |
| 46 | 46 |
| 47 DECLARE_WINDOW_PROPERTY_TYPE(const char*) | 47 DECLARE_WINDOW_PROPERTY_TYPE(const char*) |
| 48 | 48 DECLARE_WINDOW_PROPERTY_TYPE(int) |
| 49 namespace { | |
| 50 | |
| 51 class TestProperty { | |
| 52 public: | |
| 53 TestProperty() {} | |
| 54 ~TestProperty() { | |
| 55 last_deleted_ = this; | |
| 56 } | |
| 57 static TestProperty* last_deleted() { return last_deleted_; } | |
| 58 | |
| 59 private: | |
| 60 static TestProperty* last_deleted_; | |
| 61 DISALLOW_COPY_AND_ASSIGN(TestProperty); | |
| 62 }; | |
| 63 | |
| 64 TestProperty* TestProperty::last_deleted_ = nullptr; | |
| 65 | |
| 66 DEFINE_OWNED_WINDOW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL); | |
| 67 | |
| 68 } // namespace | |
| 69 | |
| 70 DECLARE_WINDOW_PROPERTY_TYPE(TestProperty*); | |
| 71 | 49 |
| 72 namespace aura { | 50 namespace aura { |
| 73 namespace test { | 51 namespace test { |
| 74 | 52 |
| 75 class WindowTest : public AuraTestBase { | 53 class WindowTest : public AuraTestBase { |
| 76 public: | 54 public: |
| 77 WindowTest() : max_separation_(0) { | 55 WindowTest() : max_separation_(0) { |
| 78 } | 56 } |
| 79 | 57 |
| 80 void SetUp() override { | 58 void SetUp() override { |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1597 w->SetNativeWindowProperty(native_prop_key, NULL); | 1575 w->SetNativeWindowProperty(native_prop_key, NULL); |
| 1598 EXPECT_EQ(NULL, w->GetNativeWindowProperty(native_prop_key)); | 1576 EXPECT_EQ(NULL, w->GetNativeWindowProperty(native_prop_key)); |
| 1599 | 1577 |
| 1600 // ClearProperty should restore the default value. | 1578 // ClearProperty should restore the default value. |
| 1601 w->ClearProperty(kIntKey); | 1579 w->ClearProperty(kIntKey); |
| 1602 EXPECT_EQ(-2, w->GetProperty(kIntKey)); | 1580 EXPECT_EQ(-2, w->GetProperty(kIntKey)); |
| 1603 w->ClearProperty(kStringKey); | 1581 w->ClearProperty(kStringKey); |
| 1604 EXPECT_EQ(std::string("squeamish"), w->GetProperty(kStringKey)); | 1582 EXPECT_EQ(std::string("squeamish"), w->GetProperty(kStringKey)); |
| 1605 } | 1583 } |
| 1606 | 1584 |
| 1585 namespace { |
| 1586 |
| 1587 class TestProperty { |
| 1588 public: |
| 1589 TestProperty() {} |
| 1590 virtual ~TestProperty() { |
| 1591 last_deleted_ = this; |
| 1592 } |
| 1593 static TestProperty* last_deleted() { return last_deleted_; } |
| 1594 |
| 1595 private: |
| 1596 static TestProperty* last_deleted_; |
| 1597 DISALLOW_COPY_AND_ASSIGN(TestProperty); |
| 1598 }; |
| 1599 |
| 1600 TestProperty* TestProperty::last_deleted_ = NULL; |
| 1601 |
| 1602 DEFINE_OWNED_WINDOW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL); |
| 1603 |
| 1604 } // namespace |
| 1605 |
| 1607 TEST_F(WindowTest, OwnedProperty) { | 1606 TEST_F(WindowTest, OwnedProperty) { |
| 1608 scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); | 1607 scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); |
| 1609 EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); | 1608 EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); |
| 1610 TestProperty* p1 = new TestProperty(); | 1609 TestProperty* p1 = new TestProperty(); |
| 1611 w->SetProperty(kOwnedKey, p1); | 1610 w->SetProperty(kOwnedKey, p1); |
| 1612 EXPECT_EQ(p1, w->GetProperty(kOwnedKey)); | 1611 EXPECT_EQ(p1, w->GetProperty(kOwnedKey)); |
| 1613 EXPECT_EQ(NULL, TestProperty::last_deleted()); | 1612 EXPECT_EQ(NULL, TestProperty::last_deleted()); |
| 1614 | 1613 |
| 1615 TestProperty* p2 = new TestProperty(); | 1614 TestProperty* p2 = new TestProperty(); |
| 1616 w->SetProperty(kOwnedKey, p2); | 1615 w->SetProperty(kOwnedKey, p2); |
| (...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3516 | 3515 |
| 3517 EXPECT_TRUE(animator.get()); | 3516 EXPECT_TRUE(animator.get()); |
| 3518 EXPECT_FALSE(animator->is_animating()); | 3517 EXPECT_FALSE(animator->is_animating()); |
| 3519 EXPECT_TRUE(observer.animation_completed()); | 3518 EXPECT_TRUE(observer.animation_completed()); |
| 3520 EXPECT_FALSE(observer.animation_aborted()); | 3519 EXPECT_FALSE(observer.animation_aborted()); |
| 3521 animator->RemoveObserver(&observer); | 3520 animator->RemoveObserver(&observer); |
| 3522 } | 3521 } |
| 3523 | 3522 |
| 3524 } // namespace test | 3523 } // namespace test |
| 3525 } // namespace aura | 3524 } // namespace aura |
| OLD | NEW |