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

Side by Side Diff: ash/shell_unittest.cc

Issue 11273059: ash: Clean up system background layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apply review feedback Created 8 years, 1 month 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 | « ash/root_window_controller.cc ('k') | ash/shell_window_ids.h » ('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) 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 "ash/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 Shell::GetPrimaryRootWindow(), 48 Shell::GetPrimaryRootWindow(),
49 internal::kShellWindowId_AlwaysOnTopContainer); 49 internal::kShellWindowId_AlwaysOnTopContainer);
50 } 50 }
51 51
52 // Expect ALL the containers! 52 // Expect ALL the containers!
53 void ExpectAllContainers() { 53 void ExpectAllContainers() {
54 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 54 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
55 EXPECT_TRUE(Shell::GetContainer( 55 EXPECT_TRUE(Shell::GetContainer(
56 root_window, internal::kShellWindowId_DesktopBackgroundContainer)); 56 root_window, internal::kShellWindowId_DesktopBackgroundContainer));
57 EXPECT_TRUE(Shell::GetContainer( 57 EXPECT_TRUE(Shell::GetContainer(
58 root_window, internal::kShellWindowId_SystemBackgroundContainer));
59 EXPECT_TRUE(Shell::GetContainer(
60 root_window, internal::kShellWindowId_DefaultContainer)); 58 root_window, internal::kShellWindowId_DefaultContainer));
61 EXPECT_TRUE(Shell::GetContainer( 59 EXPECT_TRUE(Shell::GetContainer(
62 root_window, internal::kShellWindowId_AlwaysOnTopContainer)); 60 root_window, internal::kShellWindowId_AlwaysOnTopContainer));
63 EXPECT_TRUE(Shell::GetContainer( 61 EXPECT_TRUE(Shell::GetContainer(
64 root_window, internal::kShellWindowId_PanelContainer)); 62 root_window, internal::kShellWindowId_PanelContainer));
65 EXPECT_TRUE(Shell::GetContainer( 63 EXPECT_TRUE(Shell::GetContainer(
66 root_window, internal::kShellWindowId_LauncherContainer)); 64 root_window, internal::kShellWindowId_LauncherContainer));
67 EXPECT_TRUE(Shell::GetContainer( 65 EXPECT_TRUE(Shell::GetContainer(
68 root_window, internal::kShellWindowId_SystemModalContainer)); 66 root_window, internal::kShellWindowId_SystemModalContainer));
69 EXPECT_TRUE(Shell::GetContainer( 67 EXPECT_TRUE(Shell::GetContainer(
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 std::vector<aura::Window*> results; 344 std::vector<aura::Window*> results;
347 while (window) { 345 while (window) {
348 results.push_back(window); 346 results.push_back(window);
349 window = window->parent(); 347 window = window->parent();
350 } 348 }
351 return results; 349 return results;
352 } 350 }
353 351
354 } // namespace 352 } // namespace
355 353
356 // The SystemBackgroundContainer needs to be behind the
357 // DesktopBackgroundContainer, otherwise workspace animations don't line up.
358 TEST_F(ShellTest, SystemBackgroundBehindDesktopBackground) {
359 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
360 aura::Window* desktop = Shell::GetContainer(
361 root_window, internal::kShellWindowId_DesktopBackgroundContainer);
362 ASSERT_TRUE(desktop != NULL);
363 aura::Window* system_bg = Shell::GetContainer(
364 root_window, internal::kShellWindowId_SystemBackgroundContainer);
365 ASSERT_TRUE(system_bg != NULL);
366
367 std::vector<aura::Window*> desktop_parents(BuildPathToRoot(desktop));
368 std::vector<aura::Window*> system_bg_parents(BuildPathToRoot(system_bg));
369
370 for (size_t i = 0; i < system_bg_parents.size(); ++i) {
371 std::vector<aura::Window*>::iterator desktop_i =
372 std::find(desktop_parents.begin(), desktop_parents.end(),
373 system_bg_parents[i]);
374 if (desktop_i != desktop_parents.end()) {
375 // Found the common parent.
376 ASSERT_NE(0u, i);
377 ASSERT_TRUE(desktop_i != desktop_parents.begin());
378 aura::Window* common_parent = system_bg_parents[i];
379 int system_child = static_cast<int>(std::find(
380 common_parent->children().begin(),
381 common_parent->children().end(), system_bg_parents[i - 1]) -
382 common_parent->children().begin());
383 int desktop_child = static_cast<int>(std::find(
384 common_parent->children().begin(),
385 common_parent->children().end(), *(desktop_i - 1)) -
386 common_parent->children().begin());
387 EXPECT_LT(system_child, desktop_child);
388 return;
389 }
390 }
391 EXPECT_TRUE(false) <<
392 "system background and desktop background need to have a common parent";
393 }
394
395 // Various assertions around IsAutoHideMenuHideChecked() and 354 // Various assertions around IsAutoHideMenuHideChecked() and
396 // ToggleAutoHideMenu(). 355 // ToggleAutoHideMenu().
397 TEST_F(ShellTest, ToggleAutoHide) { 356 TEST_F(ShellTest, ToggleAutoHide) {
398 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 357 scoped_ptr<aura::Window> window(new aura::Window(NULL));
399 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 358 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
400 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 359 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
401 window->Init(ui::LAYER_TEXTURED); 360 window->Init(ui::LAYER_TEXTURED);
402 window->SetParent(NULL); 361 window->SetParent(NULL);
403 window->Show(); 362 window->Show();
404 wm::ActivateWindow(window.get()); 363 wm::ActivateWindow(window.get());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 private: 404 private:
446 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 405 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
447 }; 406 };
448 407
449 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 408 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
450 window_.reset(new aura::Window(NULL)); 409 window_.reset(new aura::Window(NULL));
451 window_->Init(ui::LAYER_NOT_DRAWN); 410 window_->Init(ui::LAYER_NOT_DRAWN);
452 } 411 }
453 412
454 } // namespace ash 413 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell_window_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698