OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 6 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 7 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
| 8 #include "content/browser/tab_contents/constrained_window.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "content/browser/browser_thread.h" |
| 11 |
| 12 class ConstrainedWindowTabHelperUnit : public TabContentsWrapperTestHarness { |
| 13 public: |
| 14 ConstrainedWindowTabHelperUnit() |
| 15 : TabContentsWrapperTestHarness(), |
| 16 ui_thread_(BrowserThread::UI, &message_loop_) { |
| 17 } |
| 18 |
| 19 private: |
| 20 BrowserThread ui_thread_; |
| 21 }; |
| 22 |
| 23 class ConstrainedWindowCloseTest : public ConstrainedWindow { |
| 24 public: |
| 25 explicit ConstrainedWindowCloseTest(TabContentsWrapper* wrapper) |
| 26 : wrapper_(wrapper) { |
| 27 } |
| 28 |
| 29 virtual void ShowConstrainedWindow() {} |
| 30 virtual void FocusConstrainedWindow() {} |
| 31 virtual ~ConstrainedWindowCloseTest() {} |
| 32 |
| 33 virtual void CloseConstrainedWindow() { |
| 34 wrapper_->constrained_window_tab_helper()->WillClose(this); |
| 35 close_count++; |
| 36 } |
| 37 |
| 38 int close_count; |
| 39 TabContentsWrapper* wrapper_; |
| 40 }; |
| 41 |
| 42 TEST_F(ConstrainedWindowTabHelperUnit, ConstrainedWindows) { |
| 43 ConstrainedWindowCloseTest window(contents_wrapper()); |
| 44 window.close_count = 0; |
| 45 |
| 46 const int kWindowCount = 4; |
| 47 for (int i = 0; i < kWindowCount; i++) { |
| 48 contents_wrapper()->constrained_window_tab_helper()->AddConstrainedDialog( |
| 49 &window); |
| 50 } |
| 51 EXPECT_EQ(window.close_count, 0); |
| 52 contents_wrapper()->constrained_window_tab_helper()-> |
| 53 CloseConstrainedWindows(); |
| 54 EXPECT_EQ(window.close_count, kWindowCount); |
| 55 } |
OLD | NEW |