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 DECLARE_WINDOW_PROPERTY_TYPE(int) | 48 |
| 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*); |
49 | 71 |
50 namespace aura { | 72 namespace aura { |
51 namespace test { | 73 namespace test { |
52 | 74 |
53 class WindowTest : public AuraTestBase { | 75 class WindowTest : public AuraTestBase { |
54 public: | 76 public: |
55 WindowTest() : max_separation_(0) { | 77 WindowTest() : max_separation_(0) { |
56 } | 78 } |
57 | 79 |
58 void SetUp() override { | 80 void SetUp() override { |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 w->SetNativeWindowProperty(native_prop_key, NULL); | 1597 w->SetNativeWindowProperty(native_prop_key, NULL); |
1576 EXPECT_EQ(NULL, w->GetNativeWindowProperty(native_prop_key)); | 1598 EXPECT_EQ(NULL, w->GetNativeWindowProperty(native_prop_key)); |
1577 | 1599 |
1578 // ClearProperty should restore the default value. | 1600 // ClearProperty should restore the default value. |
1579 w->ClearProperty(kIntKey); | 1601 w->ClearProperty(kIntKey); |
1580 EXPECT_EQ(-2, w->GetProperty(kIntKey)); | 1602 EXPECT_EQ(-2, w->GetProperty(kIntKey)); |
1581 w->ClearProperty(kStringKey); | 1603 w->ClearProperty(kStringKey); |
1582 EXPECT_EQ(std::string("squeamish"), w->GetProperty(kStringKey)); | 1604 EXPECT_EQ(std::string("squeamish"), w->GetProperty(kStringKey)); |
1583 } | 1605 } |
1584 | 1606 |
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 | |
1606 TEST_F(WindowTest, OwnedProperty) { | 1607 TEST_F(WindowTest, OwnedProperty) { |
1607 scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); | 1608 scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); |
1608 EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); | 1609 EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); |
1609 TestProperty* p1 = new TestProperty(); | 1610 TestProperty* p1 = new TestProperty(); |
1610 w->SetProperty(kOwnedKey, p1); | 1611 w->SetProperty(kOwnedKey, p1); |
1611 EXPECT_EQ(p1, w->GetProperty(kOwnedKey)); | 1612 EXPECT_EQ(p1, w->GetProperty(kOwnedKey)); |
1612 EXPECT_EQ(NULL, TestProperty::last_deleted()); | 1613 EXPECT_EQ(NULL, TestProperty::last_deleted()); |
1613 | 1614 |
1614 TestProperty* p2 = new TestProperty(); | 1615 TestProperty* p2 = new TestProperty(); |
1615 w->SetProperty(kOwnedKey, p2); | 1616 w->SetProperty(kOwnedKey, p2); |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3515 | 3516 |
3516 EXPECT_TRUE(animator.get()); | 3517 EXPECT_TRUE(animator.get()); |
3517 EXPECT_FALSE(animator->is_animating()); | 3518 EXPECT_FALSE(animator->is_animating()); |
3518 EXPECT_TRUE(observer.animation_completed()); | 3519 EXPECT_TRUE(observer.animation_completed()); |
3519 EXPECT_FALSE(observer.animation_aborted()); | 3520 EXPECT_FALSE(observer.animation_aborted()); |
3520 animator->RemoveObserver(&observer); | 3521 animator->RemoveObserver(&observer); |
3521 } | 3522 } |
3522 | 3523 |
3523 } // namespace test | 3524 } // namespace test |
3524 } // namespace aura | 3525 } // namespace aura |
OLD | NEW |