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

Unified Diff: wm/foreign_window_unittest.cc

Issue 11485006: Add window manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and add proper use_wm flag support Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: wm/foreign_window_unittest.cc
diff --git a/wm/foreign_window_unittest.cc b/wm/foreign_window_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e867f299819c0952e71e4935ec3a520a35966b5a
--- /dev/null
+++ b/wm/foreign_window_unittest.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "wm/foreign_window.h"
+
+#include "base/memory/ref_counted.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window_tracker.h"
+#include "wm/foreign_test_window.h"
+#include "wm/test/wm_test_base.h"
+
+namespace wm {
+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.
+
+namespace {
+
+// Add all windows with ForeignWindows to |window_tracker|.
+void AddForeignWindowsToWindowTracker(
+ aura::Window* window,
+ aura::WindowTracker& window_tracker) {
+ if (ForeignWindow::GetForeignWindowForNativeView(window))
+ window_tracker.Add(window);
+ for (size_t i = 0; i < window->children().size(); ++i)
+ AddForeignWindowsToWindowTracker(window->children()[i], window_tracker);
+}
+
+} // namespace
+
+typedef wm::test::WmTestBase ForeignWindowTest;
+
+TEST_F(ForeignWindowTest, AddRemove) {
+ ForeignTestWindow::CreateParams params(
+ ash::Shell::GetPrimaryRootWindow()->GetAcceleratedWidget());
+ scoped_ptr<ForeignTestWindow> test_window1(new ForeignTestWindow(params));
+ scoped_ptr<ForeignTestWindow> test_window2(new ForeignTestWindow(params));
+ test_window1->Sync();
+ test_window2->Sync();
+ RunAllPendingInMessageLoop();
+ aura::WindowTracker tracker;
+ AddForeignWindowsToWindowTracker(
+ ash::Shell::GetPrimaryRootWindow(), tracker);
+ 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.
+ test_window1->Destroy();
+ test_window1->Sync();
+ RunAllPendingInMessageLoop();
+ EXPECT_EQ(1lu, tracker.windows().size());
+ test_window2->Destroy();
+ test_window2->Sync();
+ RunAllPendingInMessageLoop();
+ EXPECT_EQ(0lu, tracker.windows().size());
+}
+
+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.
+ ForeignTestWindow::CreateParams params(
+ ash::Shell::GetPrimaryRootWindow()->GetAcceleratedWidget());
+ scoped_ptr<ForeignTestWindow> test_window(new ForeignTestWindow(params));
+ test_window->Sync();
+ RunAllPendingInMessageLoop();
+ aura::WindowTracker tracker;
+ AddForeignWindowsToWindowTracker(
+ ash::Shell::GetPrimaryRootWindow(), tracker);
+ EXPECT_EQ(1lu, tracker.windows().size());
+ EXPECT_FALSE((*tracker.windows().begin())->IsVisible());
+ test_window->Show();
+ test_window->Sync();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE((*tracker.windows().begin())->IsVisible());
+ test_window->Hide();
+ test_window->Sync();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE((*tracker.windows().begin())->IsVisible());
+}
+
+} // namespace test
+} // namespace wm

Powered by Google App Engine
This is Rietveld 408576698