Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "wm/foreign_window.h" | |
| 6 | |
| 7 #include "base/memory/ref_counted.h" | |
| 8 #include "ui/aura/root_window.h" | |
| 9 #include "ui/aura/window_tracker.h" | |
| 10 #include "wm/foreign_test_window.h" | |
| 11 #include "wm/test/wm_test_base.h" | |
| 12 | |
| 13 namespace wm { | |
| 14 namespace test { | |
|
danakj
2013/02/21 01:33:15
why not anonymous for the whole file?
reveman
2013/02/22 01:26:44
trying to be consistent with ash.
| |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 // Add all windows with ForeignWindows to |window_tracker|. | |
| 19 void AddForeignWindowsToWindowTracker( | |
| 20 aura::Window* window, | |
| 21 aura::WindowTracker& window_tracker) { | |
| 22 if (ForeignWindow::GetForeignWindowForNativeView(window)) | |
| 23 window_tracker.Add(window); | |
| 24 for (size_t i = 0; i < window->children().size(); ++i) | |
| 25 AddForeignWindowsToWindowTracker(window->children()[i], window_tracker); | |
| 26 } | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 typedef wm::test::WmTestBase ForeignWindowTest; | |
| 31 | |
| 32 TEST_F(ForeignWindowTest, AddRemove) { | |
| 33 ForeignTestWindow::CreateParams params( | |
| 34 ash::Shell::GetPrimaryRootWindow()->GetAcceleratedWidget()); | |
| 35 scoped_ptr<ForeignTestWindow> test_window1(new ForeignTestWindow(params)); | |
| 36 scoped_ptr<ForeignTestWindow> test_window2(new ForeignTestWindow(params)); | |
| 37 test_window1->Sync(); | |
| 38 test_window2->Sync(); | |
| 39 RunAllPendingInMessageLoop(); | |
| 40 aura::WindowTracker tracker; | |
| 41 AddForeignWindowsToWindowTracker( | |
| 42 ash::Shell::GetPrimaryRootWindow(), tracker); | |
| 43 EXPECT_EQ(2lu, tracker.windows().size()); | |
|
danakj
2013/02/21 01:33:15
is 2u not enough?
reveman
2013/02/22 01:26:44
Done.
| |
| 44 test_window1->Destroy(); | |
| 45 test_window1->Sync(); | |
| 46 RunAllPendingInMessageLoop(); | |
| 47 EXPECT_EQ(1lu, tracker.windows().size()); | |
| 48 test_window2->Destroy(); | |
| 49 test_window2->Sync(); | |
| 50 RunAllPendingInMessageLoop(); | |
| 51 EXPECT_EQ(0lu, tracker.windows().size()); | |
| 52 } | |
| 53 | |
| 54 TEST_F(ForeignWindowTest, IsVisible) { | |
|
danakj
2013/02/21 01:33:15
can you stick a comment on/in each of these tests
reveman
2013/02/22 01:26:44
Done.
| |
| 55 ForeignTestWindow::CreateParams params( | |
| 56 ash::Shell::GetPrimaryRootWindow()->GetAcceleratedWidget()); | |
| 57 scoped_ptr<ForeignTestWindow> test_window(new ForeignTestWindow(params)); | |
| 58 test_window->Sync(); | |
| 59 RunAllPendingInMessageLoop(); | |
| 60 aura::WindowTracker tracker; | |
| 61 AddForeignWindowsToWindowTracker( | |
| 62 ash::Shell::GetPrimaryRootWindow(), tracker); | |
| 63 EXPECT_EQ(1lu, tracker.windows().size()); | |
| 64 EXPECT_FALSE((*tracker.windows().begin())->IsVisible()); | |
| 65 test_window->Show(); | |
| 66 test_window->Sync(); | |
| 67 RunAllPendingInMessageLoop(); | |
| 68 EXPECT_TRUE((*tracker.windows().begin())->IsVisible()); | |
| 69 test_window->Hide(); | |
| 70 test_window->Sync(); | |
| 71 RunAllPendingInMessageLoop(); | |
| 72 EXPECT_FALSE((*tracker.windows().begin())->IsVisible()); | |
| 73 } | |
| 74 | |
| 75 } // namespace test | |
| 76 } // namespace wm | |
| OLD | NEW |