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 29 matching lines...) Expand all Loading... | |
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 DECLARE_WINDOW_PROPERTY_TYPE(int) |
49 | 49 |
50 namespace { | |
51 | |
52 class TestProperty { | |
53 public: | |
54 TestProperty() {} | |
55 virtual ~TestProperty() { | |
sky
2014/12/18 17:46:08
nit: no virtual but override.
oshima
2014/12/18 18:14:42
Done.
| |
56 last_deleted_ = this; | |
57 } | |
58 static TestProperty* last_deleted() { return last_deleted_; } | |
59 | |
60 private: | |
61 static TestProperty* last_deleted_; | |
62 DISALLOW_COPY_AND_ASSIGN(TestProperty); | |
63 }; | |
64 | |
65 TestProperty* TestProperty::last_deleted_ = NULL; | |
sky
2014/12/18 17:46:08
nullptr
oshima
2014/12/18 18:14:42
Done.
| |
66 | |
67 DEFINE_OWNED_WINDOW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL); | |
68 | |
69 } // namespace | |
70 | |
71 DECLARE_WINDOW_PROPERTY_TYPE(TestProperty*); | |
72 | |
50 namespace aura { | 73 namespace aura { |
51 namespace test { | 74 namespace test { |
52 | 75 |
53 class WindowTest : public AuraTestBase { | 76 class WindowTest : public AuraTestBase { |
54 public: | 77 public: |
55 WindowTest() : max_separation_(0) { | 78 WindowTest() : max_separation_(0) { |
56 } | 79 } |
57 | 80 |
58 void SetUp() override { | 81 void SetUp() override { |
59 AuraTestBase::SetUp(); | 82 AuraTestBase::SetUp(); |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1575 w->SetNativeWindowProperty(native_prop_key, NULL); | 1598 w->SetNativeWindowProperty(native_prop_key, NULL); |
1576 EXPECT_EQ(NULL, w->GetNativeWindowProperty(native_prop_key)); | 1599 EXPECT_EQ(NULL, w->GetNativeWindowProperty(native_prop_key)); |
1577 | 1600 |
1578 // ClearProperty should restore the default value. | 1601 // ClearProperty should restore the default value. |
1579 w->ClearProperty(kIntKey); | 1602 w->ClearProperty(kIntKey); |
1580 EXPECT_EQ(-2, w->GetProperty(kIntKey)); | 1603 EXPECT_EQ(-2, w->GetProperty(kIntKey)); |
1581 w->ClearProperty(kStringKey); | 1604 w->ClearProperty(kStringKey); |
1582 EXPECT_EQ(std::string("squeamish"), w->GetProperty(kStringKey)); | 1605 EXPECT_EQ(std::string("squeamish"), w->GetProperty(kStringKey)); |
1583 } | 1606 } |
1584 | 1607 |
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) { | 1608 TEST_F(WindowTest, OwnedProperty) { |
1607 scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); | 1609 scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); |
1608 EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); | 1610 EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); |
1609 TestProperty* p1 = new TestProperty(); | 1611 TestProperty* p1 = new TestProperty(); |
1610 w->SetProperty(kOwnedKey, p1); | 1612 w->SetProperty(kOwnedKey, p1); |
1611 EXPECT_EQ(p1, w->GetProperty(kOwnedKey)); | 1613 EXPECT_EQ(p1, w->GetProperty(kOwnedKey)); |
1612 EXPECT_EQ(NULL, TestProperty::last_deleted()); | 1614 EXPECT_EQ(NULL, TestProperty::last_deleted()); |
1613 | 1615 |
1614 TestProperty* p2 = new TestProperty(); | 1616 TestProperty* p2 = new TestProperty(); |
1615 w->SetProperty(kOwnedKey, p2); | 1617 w->SetProperty(kOwnedKey, p2); |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3515 | 3517 |
3516 EXPECT_TRUE(animator.get()); | 3518 EXPECT_TRUE(animator.get()); |
3517 EXPECT_FALSE(animator->is_animating()); | 3519 EXPECT_FALSE(animator->is_animating()); |
3518 EXPECT_TRUE(observer.animation_completed()); | 3520 EXPECT_TRUE(observer.animation_completed()); |
3519 EXPECT_FALSE(observer.animation_aborted()); | 3521 EXPECT_FALSE(observer.animation_aborted()); |
3520 animator->RemoveObserver(&observer); | 3522 animator->RemoveObserver(&observer); |
3521 } | 3523 } |
3522 | 3524 |
3523 } // namespace test | 3525 } // namespace test |
3524 } // namespace aura | 3526 } // namespace aura |
OLD | NEW |