Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: ui/aura/window_unittest.cc

Issue 8620002: s/Move/Stack/ in names of stacking-related methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a test Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.cc ('k') | ui/aura_shell/modal_container_layout_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), NULL)); 237 CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), NULL));
238 CreateTestWindowWithDelegate(&child_delegate, 0, gfx::Rect(), parent.get()); 238 CreateTestWindowWithDelegate(&child_delegate, 0, gfx::Rect(), parent.get());
239 } 239 }
240 // Both the parent and child should have been destroyed. 240 // Both the parent and child should have been destroyed.
241 EXPECT_EQ(1, parent_delegate.destroying_count()); 241 EXPECT_EQ(1, parent_delegate.destroying_count());
242 EXPECT_EQ(1, parent_delegate.destroyed_count()); 242 EXPECT_EQ(1, parent_delegate.destroyed_count());
243 EXPECT_EQ(1, child_delegate.destroying_count()); 243 EXPECT_EQ(1, child_delegate.destroying_count());
244 EXPECT_EQ(1, child_delegate.destroyed_count()); 244 EXPECT_EQ(1, child_delegate.destroyed_count());
245 } 245 }
246 246
247 // Make sure MoveChildToFront moves both the window and layer to the front. 247 // Make sure StackChildAtTop moves both the window and layer to the front.
248 TEST_F(WindowTest, MoveChildToFront) { 248 TEST_F(WindowTest, StackChildAtTop) {
249 Window parent(NULL); 249 Window parent(NULL);
250 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 250 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
251 Window child1(NULL); 251 Window child1(NULL);
252 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 252 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
253 Window child2(NULL); 253 Window child2(NULL);
254 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 254 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
255 255
256 child1.SetParent(&parent); 256 child1.SetParent(&parent);
257 child2.SetParent(&parent); 257 child2.SetParent(&parent);
258 ASSERT_EQ(2u, parent.children().size()); 258 ASSERT_EQ(2u, parent.children().size());
259 EXPECT_EQ(&child1, parent.children()[0]); 259 EXPECT_EQ(&child1, parent.children()[0]);
260 EXPECT_EQ(&child2, parent.children()[1]); 260 EXPECT_EQ(&child2, parent.children()[1]);
261 ASSERT_EQ(2u, parent.layer()->children().size()); 261 ASSERT_EQ(2u, parent.layer()->children().size());
262 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]); 262 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]);
263 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]); 263 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]);
264 264
265 parent.MoveChildToFront(&child1); 265 parent.StackChildAtTop(&child1);
266 ASSERT_EQ(2u, parent.children().size()); 266 ASSERT_EQ(2u, parent.children().size());
267 EXPECT_EQ(&child1, parent.children()[1]); 267 EXPECT_EQ(&child1, parent.children()[1]);
268 EXPECT_EQ(&child2, parent.children()[0]); 268 EXPECT_EQ(&child2, parent.children()[0]);
269 ASSERT_EQ(2u, parent.layer()->children().size()); 269 ASSERT_EQ(2u, parent.layer()->children().size());
270 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); 270 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]);
271 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); 271 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
272 } 272 }
273 273
274 // Various assertions for MoveToFront. 274 // Various assertions for StackAtTop.
275 TEST_F(WindowTest, MoveToFront) { 275 TEST_F(WindowTest, StackAtTop) {
276 Window parent(NULL); 276 Window parent(NULL);
277 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 277 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
278 Window child1(NULL); 278 Window child1(NULL);
279 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 279 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
280 Window child2(NULL); 280 Window child2(NULL);
281 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 281 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
282 Window child3(NULL); 282 Window child3(NULL);
283 child3.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 283 child3.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
284 284
285 child1.SetParent(&parent); 285 child1.SetParent(&parent);
286 child2.SetParent(&parent); 286 child2.SetParent(&parent);
287 287
288 // Move 1 in front of 2. 288 // Move 1 in front of 2.
289 parent.MoveChildAbove(&child1, &child2); 289 parent.StackChildAbove(&child1, &child2);
290 ASSERT_EQ(2u, parent.children().size()); 290 ASSERT_EQ(2u, parent.children().size());
291 EXPECT_EQ(&child2, parent.children()[0]); 291 EXPECT_EQ(&child2, parent.children()[0]);
292 EXPECT_EQ(&child1, parent.children()[1]); 292 EXPECT_EQ(&child1, parent.children()[1]);
293 ASSERT_EQ(2u, parent.layer()->children().size()); 293 ASSERT_EQ(2u, parent.layer()->children().size());
294 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); 294 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
295 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); 295 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]);
296 296
297 // Add 3, resulting in order [2, 1, 3], then move 2 in front of 1, resulting 297 // Add 3, resulting in order [2, 1, 3], then move 2 in front of 1, resulting
298 // in [1, 2, 3]. 298 // in [1, 2, 3].
299 child3.SetParent(&parent); 299 child3.SetParent(&parent);
300 parent.MoveChildAbove(&child2, &child1); 300 parent.StackChildAbove(&child2, &child1);
301 ASSERT_EQ(3u, parent.children().size()); 301 ASSERT_EQ(3u, parent.children().size());
302 EXPECT_EQ(&child1, parent.children()[0]); 302 EXPECT_EQ(&child1, parent.children()[0]);
303 EXPECT_EQ(&child2, parent.children()[1]); 303 EXPECT_EQ(&child2, parent.children()[1]);
304 EXPECT_EQ(&child3, parent.children()[2]); 304 EXPECT_EQ(&child3, parent.children()[2]);
305 ASSERT_EQ(3u, parent.layer()->children().size()); 305 ASSERT_EQ(3u, parent.layer()->children().size());
306 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]); 306 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]);
307 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]); 307 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]);
308 EXPECT_EQ(child3.layer(), parent.layer()->children()[2]); 308 EXPECT_EQ(child3.layer(), parent.layer()->children()[2]);
309 309
310 // Move 1 in front of 3, resulting in [2 3 1]. 310 // Move 1 in front of 3, resulting in [2 3 1].
311 parent.MoveChildAbove(&child1, &child3); 311 parent.StackChildAbove(&child1, &child3);
312 ASSERT_EQ(3u, parent.children().size()); 312 ASSERT_EQ(3u, parent.children().size());
313 EXPECT_EQ(&child2, parent.children()[0]); 313 EXPECT_EQ(&child2, parent.children()[0]);
314 EXPECT_EQ(&child3, parent.children()[1]); 314 EXPECT_EQ(&child3, parent.children()[1]);
315 EXPECT_EQ(&child1, parent.children()[2]); 315 EXPECT_EQ(&child1, parent.children()[2]);
316 ASSERT_EQ(3u, parent.layer()->children().size()); 316 ASSERT_EQ(3u, parent.layer()->children().size());
317 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); 317 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
318 EXPECT_EQ(child3.layer(), parent.layer()->children()[1]); 318 EXPECT_EQ(child3.layer(), parent.layer()->children()[1]);
319 EXPECT_EQ(child1.layer(), parent.layer()->children()[2]); 319 EXPECT_EQ(child1.layer(), parent.layer()->children()[2]);
320 } 320 }
321 321
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()).ToString()); 747 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()).ToString());
748 } 748 }
749 749
750 // Various assertions for transient children. 750 // Various assertions for transient children.
751 TEST_F(WindowTest, TransientChildren) { 751 TEST_F(WindowTest, TransientChildren) {
752 scoped_ptr<Window> parent(CreateTestWindowWithId(0, NULL)); 752 scoped_ptr<Window> parent(CreateTestWindowWithId(0, NULL));
753 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get())); 753 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get()));
754 scoped_ptr<Window> w3(CreateTestWindowWithId(3, parent.get())); 754 scoped_ptr<Window> w3(CreateTestWindowWithId(3, parent.get()));
755 Window* w2 = CreateTestWindowWithId(2, parent.get()); 755 Window* w2 = CreateTestWindowWithId(2, parent.get());
756 w1->AddTransientChild(w2); // w2 is now owned by w1. 756 w1->AddTransientChild(w2); // w2 is now owned by w1.
757 // Move w1 to the front (end), this should force w2 to be last (on top of w1). 757 // Stack w1 at the top (end), this should force w2 to be last (on top of w1).
758 parent->MoveChildToFront(w1.get()); 758 parent->StackChildAtTop(w1.get());
759 ASSERT_EQ(3u, parent->children().size()); 759 ASSERT_EQ(3u, parent->children().size());
760 EXPECT_EQ(w2, parent->children().back()); 760 EXPECT_EQ(w2, parent->children().back());
761 761
762 // Destroy w1, which should also destroy w3 (since it's a transient child). 762 // Destroy w1, which should also destroy w3 (since it's a transient child).
763 w1.reset(); 763 w1.reset();
764 w2 = NULL; 764 w2 = NULL;
765 ASSERT_EQ(1u, parent->children().size()); 765 ASSERT_EQ(1u, parent->children().size());
766 EXPECT_EQ(w3.get(), parent->children()[0]); 766 EXPECT_EQ(w3.get(), parent->children()[0]);
767 767
768 w1.reset(CreateTestWindowWithId(4, parent.get())); 768 w1.reset(CreateTestWindowWithId(4, parent.get()));
769 w2 = CreateTestWindowWithId(5, w3.get()); 769 w2 = CreateTestWindowWithId(5, w3.get());
770 w1->AddTransientChild(w2); 770 w1->AddTransientChild(w2);
771 parent->MoveChildToFront(w3.get()); 771 parent->StackChildAtTop(w3.get());
772 // Move w1 to the front (end), this shouldn't effect w2 since it has a 772 // Stack w1 at the top (end), this shouldn't affect w2 since it has a
773 // different parent. 773 // different parent.
774 parent->MoveChildToFront(w1.get()); 774 parent->StackChildAtTop(w1.get());
775 ASSERT_EQ(2u, parent->children().size()); 775 ASSERT_EQ(2u, parent->children().size());
776 EXPECT_EQ(w3.get(), parent->children()[0]); 776 EXPECT_EQ(w3.get(), parent->children()[0]);
777 EXPECT_EQ(w1.get(), parent->children()[1]); 777 EXPECT_EQ(w1.get(), parent->children()[1]);
778 } 778 }
779 779
780 TEST_F(WindowTest, Property) { 780 TEST_F(WindowTest, Property) {
781 scoped_ptr<Window> w(CreateTestWindowWithId(0, NULL)); 781 scoped_ptr<Window> w(CreateTestWindowWithId(0, NULL));
782 const char* key = "test"; 782 const char* key = "test";
783 EXPECT_EQ(NULL, w->GetProperty(key)); 783 EXPECT_EQ(NULL, w->GetProperty(key));
784 EXPECT_EQ(0, w->GetIntProperty(key)); 784 EXPECT_EQ(0, w->GetIntProperty(key));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1086
1087 w3->Activate(); 1087 w3->Activate();
1088 EXPECT_EQ(w2.get(), active()); 1088 EXPECT_EQ(w2.get(), active());
1089 1089
1090 w1->Activate(); 1090 w1->Activate();
1091 EXPECT_EQ(w1.get(), active()); 1091 EXPECT_EQ(w1.get(), active());
1092 } 1092 }
1093 1093
1094 } // namespace test 1094 } // namespace test
1095 } // namespace aura 1095 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | ui/aura_shell/modal_container_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698