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

Side by Side Diff: components/web_modal/web_contents_modal_dialog_manager_unittest.cc

Issue 14969012: components: Create web_modal component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-gtk-build Created 7 years, 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/native_web_contents_modal_dialog_manager.h" 5 #include "components/web_modal/native_web_contents_modal_dialog_manager.h"
6 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 6 #include "components/web_modal/web_contents_modal_dialog_manager.h"
7 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
8 #include "content/public/test/test_browser_thread.h" 7 #include "content/public/test/test_browser_thread.h"
8 #include "content/public/test/test_renderer_host.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using content::BrowserThread; 11 using content::BrowserThread;
12 12
13 namespace web_modal {
14
15 class TestNativeWebContentsModalDialogManager :
16 public NativeWebContentsModalDialogManager {
17 public:
18 TestNativeWebContentsModalDialogManager() {}
19 virtual ~TestNativeWebContentsModalDialogManager() {}
20
21 private:
22 // Overridden from NativeWebContentsModalDialog:
23 virtual void ManageDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
24 virtual void ShowDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
25 virtual void HideDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
26 virtual void CloseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
27 virtual void FocusDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
28 virtual void PulseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
29
30 DISALLOW_COPY_AND_ASSIGN(TestNativeWebContentsModalDialogManager);
31 };
32
33 NativeWebContentsModalDialogManager* WebContentsModalDialogManager::
34 CreateNativeManager(
35 NativeWebContentsModalDialogManagerDelegate* native_delegate) {
36 return new TestNativeWebContentsModalDialogManager();
Mike Wittman 2013/05/10 00:03:22 This can probably return a new NativeWebContentsMo
sadrul 2013/05/10 02:59:18 Ah, cool. I didn't actually notice NWCMDMCloseTest
37 }
38
13 class WebContentsModalDialogManagerTest 39 class WebContentsModalDialogManagerTest
14 : public ChromeRenderViewHostTestHarness { 40 : public content::RenderViewHostTestHarness {
15 public: 41 public:
16 WebContentsModalDialogManagerTest() 42 WebContentsModalDialogManagerTest()
17 : ChromeRenderViewHostTestHarness(), 43 : ui_thread_(BrowserThread::UI, &message_loop_) {
18 ui_thread_(BrowserThread::UI, &message_loop_) {
19 } 44 }
20 45
21 virtual void SetUp() { 46 virtual void SetUp() {
22 ChromeRenderViewHostTestHarness::SetUp(); 47 content::RenderViewHostTestHarness::SetUp();
23 WebContentsModalDialogManager::CreateForWebContents(web_contents()); 48 WebContentsModalDialogManager::CreateForWebContents(web_contents());
24 } 49 }
25 50
26 private: 51 private:
27 content::TestBrowserThread ui_thread_; 52 content::TestBrowserThread ui_thread_;
28 }; 53 };
29 54
30 class NativeWebContentsModalDialogManagerCloseTest 55 class NativeWebContentsModalDialogManagerCloseTest
31 : public NativeWebContentsModalDialogManager { 56 : public NativeWebContentsModalDialogManager {
32 public: 57 public:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // WebContentsModalDialogManager treats the NativeWebContentsModalDialog as 95 // WebContentsModalDialogManager treats the NativeWebContentsModalDialog as
71 // an opaque type, so creating fake NativeWebContentsModalDialogs using 96 // an opaque type, so creating fake NativeWebContentsModalDialogs using
72 // reinterpret_cast is valid. 97 // reinterpret_cast is valid.
73 web_contents_modal_dialog_manager->ShowDialog( 98 web_contents_modal_dialog_manager->ShowDialog(
74 reinterpret_cast<NativeWebContentsModalDialog>(i)); 99 reinterpret_cast<NativeWebContentsModalDialog>(i));
75 EXPECT_EQ(native_manager->close_count, 0); 100 EXPECT_EQ(native_manager->close_count, 0);
76 101
77 test_api.CloseAllDialogs(); 102 test_api.CloseAllDialogs();
78 EXPECT_EQ(native_manager->close_count, kWindowCount); 103 EXPECT_EQ(native_manager->close_count, kWindowCount);
79 } 104 }
105
106 } // namespace web_modal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698