| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/aura/desktop.h" | 11 #include "ui/aura/desktop.h" |
| 12 #include "ui/aura/desktop_observer.h" | 12 #include "ui/aura/desktop_observer.h" |
| 13 #include "ui/aura/event.h" | 13 #include "ui/aura/event.h" |
| 14 #include "ui/aura/focus_manager.h" | 14 #include "ui/aura/focus_manager.h" |
| 15 #include "ui/aura/hit_test.h" | 15 #include "ui/aura/hit_test.h" |
| 16 #include "ui/aura/test/aura_test_base.h" | 16 #include "ui/aura/test/aura_test_base.h" |
| 17 #include "ui/aura/test/event_generator.h" | 17 #include "ui/aura/test/event_generator.h" |
| 18 #include "ui/aura/test/test_desktop_delegate.h" | 18 #include "ui/aura/test/test_desktop_delegate.h" |
| 19 #include "ui/aura/test/test_window_delegate.h" | 19 #include "ui/aura/test/test_window_delegate.h" |
| 20 #include "ui/aura/window_delegate.h" | 20 #include "ui/aura/window_delegate.h" |
| 21 #include "ui/aura/window_observer.h" | 21 #include "ui/aura/window_observer.h" |
| 22 #include "ui/base/keycodes/keyboard_codes.h" | 22 #include "ui/base/keycodes/keyboard_codes.h" |
| 23 #include "ui/base/view_prop.h" | |
| 24 #include "ui/gfx/canvas_skia.h" | 23 #include "ui/gfx/canvas_skia.h" |
| 25 #include "ui/gfx/compositor/layer.h" | 24 #include "ui/gfx/compositor/layer.h" |
| 26 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
| 27 | 26 |
| 28 namespace aura { | 27 namespace aura { |
| 29 namespace test { | 28 namespace test { |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 // Used for verifying destruction methods are invoked. | 32 // Used for verifying destruction methods are invoked. |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 desktop_size.height() + 200)); | 1131 desktop_size.height() + 200)); |
| 1133 | 1132 |
| 1134 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(w1.get()), w1->bounds()); | 1133 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(w1.get()), w1->bounds()); |
| 1135 | 1134 |
| 1136 w1->Restore(); | 1135 w1->Restore(); |
| 1137 EXPECT_EQ(window_bounds, w1->bounds()); | 1136 EXPECT_EQ(window_bounds, w1->bounds()); |
| 1138 } | 1137 } |
| 1139 | 1138 |
| 1140 TEST_F(WindowTest, Property) { | 1139 TEST_F(WindowTest, Property) { |
| 1141 scoped_ptr<Window> w(CreateTestWindowWithId(0, NULL)); | 1140 scoped_ptr<Window> w(CreateTestWindowWithId(0, NULL)); |
| 1142 const gfx::NativeView target = const_cast<const gfx::NativeView>(w.get()); | |
| 1143 const char* key = "test"; | 1141 const char* key = "test"; |
| 1144 EXPECT_EQ(NULL, w->GetProperty(key)); | 1142 EXPECT_EQ(NULL, w->GetProperty(key)); |
| 1145 EXPECT_EQ(NULL, ui::ViewProp::GetValue(target, key)); | |
| 1146 | 1143 |
| 1147 void* value = reinterpret_cast<void*>(static_cast<intptr_t>(1)); | 1144 void* value = reinterpret_cast<void*>(static_cast<intptr_t>(1)); |
| 1148 w->SetProperty(key, value); | 1145 w->SetProperty(key, value); |
| 1149 EXPECT_EQ(value, w->GetProperty(key)); | 1146 EXPECT_EQ(value, w->GetProperty(key)); |
| 1150 EXPECT_EQ(value, ui::ViewProp::GetValue(target, key)); | |
| 1151 | 1147 |
| 1152 // Overwrite the property with different value type. | 1148 // Overwrite the property with different value type. |
| 1153 w->SetProperty(key, static_cast<void*>(const_cast<char*>("string"))); | 1149 w->SetProperty(key, static_cast<void*>(const_cast<char*>("string"))); |
| 1154 std::string expected("string"); | 1150 std::string expected("string"); |
| 1155 EXPECT_EQ(expected, | 1151 EXPECT_EQ(expected, |
| 1156 static_cast<const char*>(w->GetProperty(key))); | 1152 static_cast<const char*>(w->GetProperty(key))); |
| 1157 EXPECT_EQ(expected, | |
| 1158 static_cast<const char*>(ui::ViewProp::GetValue(target, key))); | |
| 1159 | 1153 |
| 1160 // Non-existent property. | 1154 // Non-existent property. |
| 1161 EXPECT_EQ(NULL, w->GetProperty("foo")); | 1155 EXPECT_EQ(NULL, w->GetProperty("foo")); |
| 1162 EXPECT_EQ(NULL, ui::ViewProp::GetValue(target, "foo")); | |
| 1163 | 1156 |
| 1164 // Set NULL and make sure the property is gone. | 1157 // Set NULL and make sure the property is gone. |
| 1165 w->SetProperty(key, NULL); | 1158 w->SetProperty(key, NULL); |
| 1166 EXPECT_EQ(NULL, w->GetProperty(key)); | 1159 EXPECT_EQ(NULL, w->GetProperty(key)); |
| 1167 EXPECT_EQ(NULL, ui::ViewProp::GetValue(target, key)); | |
| 1168 } | 1160 } |
| 1169 | 1161 |
| 1170 class WindowObserverTest : public WindowTest, | 1162 class WindowObserverTest : public WindowTest, |
| 1171 public WindowObserver { | 1163 public WindowObserver { |
| 1172 public: | 1164 public: |
| 1173 struct VisibilityInfo { | 1165 struct VisibilityInfo { |
| 1174 bool window_visible; | 1166 bool window_visible; |
| 1175 bool visible_param; | 1167 bool visible_param; |
| 1176 }; | 1168 }; |
| 1177 | 1169 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 | 1354 |
| 1363 w3->Activate(); | 1355 w3->Activate(); |
| 1364 EXPECT_EQ(w2.get(), active()); | 1356 EXPECT_EQ(w2.get(), active()); |
| 1365 | 1357 |
| 1366 w1->Activate(); | 1358 w1->Activate(); |
| 1367 EXPECT_EQ(w1.get(), active()); | 1359 EXPECT_EQ(w1.get(), active()); |
| 1368 } | 1360 } |
| 1369 | 1361 |
| 1370 } // namespace test | 1362 } // namespace test |
| 1371 } // namespace aura | 1363 } // namespace aura |
| OLD | NEW |