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

Side by Side Diff: chrome/browser/ui/constrained_window_tab_helper_unittest.cc

Issue 11633052: Rename platform-independent ConstrainedWindow types to WebContentsModalDialog types (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use gtk_widget_get_toplevel for GetNativeWindow Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "chrome/browser/ui/constrained_window.h"
6 #include "chrome/browser/ui/constrained_window_tab_helper.h"
7 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
8 #include "content/public/test/test_browser_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 using content::BrowserThread;
12
13 class ConstrainedWindowTabHelperTest : public ChromeRenderViewHostTestHarness {
14 public:
15 ConstrainedWindowTabHelperTest()
16 : ChromeRenderViewHostTestHarness(),
17 ui_thread_(BrowserThread::UI, &message_loop_) {
18 }
19
20 virtual void SetUp() {
21 ChromeRenderViewHostTestHarness::SetUp();
22 ConstrainedWindowTabHelper::CreateForWebContents(web_contents());
23 }
24
25 private:
26 content::TestBrowserThread ui_thread_;
27 };
28
29 class WebContentsModalDialogCloseTest : public ConstrainedWindow {
30 public:
31 explicit WebContentsModalDialogCloseTest(content::WebContents* web_contents)
32 : web_contents_(web_contents) {
33 }
34
35 virtual void ShowWebContentsModalDialog() {}
36 virtual void FocusWebContentsModalDialog() {}
37 virtual ~WebContentsModalDialogCloseTest() {}
38
39 virtual void CloseWebContentsModalDialog() {
40 ConstrainedWindowTabHelper* constrained_window_tab_helper =
41 ConstrainedWindowTabHelper::FromWebContents(web_contents_);
42 constrained_window_tab_helper->WillClose(this);
43 close_count++;
44 }
45
46 int close_count;
47 content::WebContents* web_contents_;
48 };
49
50 TEST_F(ConstrainedWindowTabHelperTest, ConstrainedWindows) {
51 WebContentsModalDialogCloseTest window(web_contents());
52 window.close_count = 0;
53 ConstrainedWindowTabHelper* constrained_window_tab_helper =
54 ConstrainedWindowTabHelper::FromWebContents(web_contents());
55
56 const int kWindowCount = 4;
57 for (int i = 0; i < kWindowCount; i++)
58 constrained_window_tab_helper->AddDialog(&window);
59 EXPECT_EQ(window.close_count, 0);
60
61 constrained_window_tab_helper->CloseAllDialogs();
62 EXPECT_EQ(window.close_count, kWindowCount);
63 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/constrained_window_tab_helper_delegate.cc ('k') | chrome/browser/ui/extensions/shell_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698