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

Unified Diff: chrome/browser/ui/constrained_window_tab_helper_unittest.cc

Issue 7880003: content: Move constrained window code from TabContents to TabContentsWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac regression now that shutdown timing was changed for views. Created 9 years, 3 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: chrome/browser/ui/constrained_window_tab_helper_unittest.cc
diff --git a/chrome/browser/ui/constrained_window_tab_helper_unittest.cc b/chrome/browser/ui/constrained_window_tab_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c426d39104d0da1da594229a4a9001ae310a328
--- /dev/null
+++ b/chrome/browser/ui/constrained_window_tab_helper_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2011 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 "chrome/browser/ui/constrained_window_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
+#include "content/browser/tab_contents/constrained_window.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "content/browser/browser_thread.h"
+
+class ConstrainedWindowTabHelperUnit : public TabContentsWrapperTestHarness {
+ public:
+ ConstrainedWindowTabHelperUnit()
+ : TabContentsWrapperTestHarness(),
+ ui_thread_(BrowserThread::UI, &message_loop_) {
+ }
+
+ private:
+ BrowserThread ui_thread_;
+};
+
+class ConstrainedWindowCloseTest : public ConstrainedWindow {
+ public:
+ explicit ConstrainedWindowCloseTest(TabContentsWrapper* wrapper)
+ : wrapper_(wrapper) {
+ }
+
+ virtual void ShowConstrainedWindow() {}
+ virtual void FocusConstrainedWindow() {}
+ virtual ~ConstrainedWindowCloseTest() {}
+
+ virtual void CloseConstrainedWindow() {
+ wrapper_->constrained_window_tab_helper()->WillClose(this);
+ close_count++;
+ }
+
+ int close_count;
+ TabContentsWrapper* wrapper_;
+};
+
+TEST_F(ConstrainedWindowTabHelperUnit, ConstrainedWindows) {
+ ConstrainedWindowCloseTest window(contents_wrapper());
+ window.close_count = 0;
+
+ const int kWindowCount = 4;
+ for (int i = 0; i < kWindowCount; i++) {
+ contents_wrapper()->constrained_window_tab_helper()->AddConstrainedDialog(
+ &window);
+ }
+ EXPECT_EQ(window.close_count, 0);
+ contents_wrapper()->constrained_window_tab_helper()->
+ CloseConstrainedWindows();
+ EXPECT_EQ(window.close_count, kWindowCount);
+}

Powered by Google App Engine
This is Rietveld 408576698