OLD | NEW |
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 "components/web_modal/native_web_contents_modal_dialog_manager.h" | 5 #include "components/web_modal/native_web_contents_modal_dialog_manager.h" |
6 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 6 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
7 #include "content/public/test/test_browser_thread.h" | |
8 #include "content/public/test/test_renderer_host.h" | 7 #include "content/public/test/test_renderer_host.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
10 | 9 |
11 using content::BrowserThread; | 10 using content::BrowserThread; |
12 | 11 |
13 namespace web_modal { | 12 namespace web_modal { |
14 | 13 |
15 class WebContentsModalDialogManagerTest | 14 class WebContentsModalDialogManagerTest |
16 : public content::RenderViewHostTestHarness { | 15 : public content::RenderViewHostTestHarness { |
17 public: | 16 public: |
18 WebContentsModalDialogManagerTest() | |
19 : ui_thread_(BrowserThread::UI, &message_loop_) { | |
20 } | |
21 | |
22 virtual void SetUp() { | 17 virtual void SetUp() { |
23 content::RenderViewHostTestHarness::SetUp(); | 18 content::RenderViewHostTestHarness::SetUp(); |
24 WebContentsModalDialogManager::CreateForWebContents(web_contents()); | 19 WebContentsModalDialogManager::CreateForWebContents(web_contents()); |
25 } | 20 } |
26 | |
27 private: | |
28 content::TestBrowserThread ui_thread_; | |
29 }; | 21 }; |
30 | 22 |
31 class NativeWebContentsModalDialogManagerCloseTest | 23 class NativeWebContentsModalDialogManagerCloseTest |
32 : public NativeWebContentsModalDialogManager { | 24 : public NativeWebContentsModalDialogManager { |
33 public: | 25 public: |
34 NativeWebContentsModalDialogManagerCloseTest( | 26 NativeWebContentsModalDialogManagerCloseTest( |
35 NativeWebContentsModalDialogManagerDelegate* delegate) | 27 NativeWebContentsModalDialogManagerDelegate* delegate) |
36 : delegate_(delegate) {} | 28 : delegate_(delegate) {} |
37 virtual void ManageDialog(NativeWebContentsModalDialog dialog) OVERRIDE { | 29 virtual void ManageDialog(NativeWebContentsModalDialog dialog) OVERRIDE { |
38 } | 30 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // reinterpret_cast is valid. | 71 // reinterpret_cast is valid. |
80 web_contents_modal_dialog_manager->ShowDialog( | 72 web_contents_modal_dialog_manager->ShowDialog( |
81 reinterpret_cast<NativeWebContentsModalDialog>(i)); | 73 reinterpret_cast<NativeWebContentsModalDialog>(i)); |
82 EXPECT_EQ(native_manager->close_count, 0); | 74 EXPECT_EQ(native_manager->close_count, 0); |
83 | 75 |
84 test_api.CloseAllDialogs(); | 76 test_api.CloseAllDialogs(); |
85 EXPECT_EQ(native_manager->close_count, kWindowCount); | 77 EXPECT_EQ(native_manager->close_count, kWindowCount); |
86 } | 78 } |
87 | 79 |
88 } // namespace web_modal | 80 } // namespace web_modal |
OLD | NEW |