| 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 "chrome/browser/ui/web_contents_modal_dialog.h" | 5 #include "chrome/browser/ui/web_contents_modal_dialog.h" |
| 6 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 6 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
| 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 8 #include "content/public/test/test_browser_thread.h" | 8 #include "content/public/test/test_browser_thread.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 virtual void ShowWebContentsModalDialog() {} | 36 virtual void ShowWebContentsModalDialog() {} |
| 37 virtual void CloseWebContentsModalDialog() { | 37 virtual void CloseWebContentsModalDialog() { |
| 38 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 38 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 39 WebContentsModalDialogManager::FromWebContents(web_contents_); | 39 WebContentsModalDialogManager::FromWebContents(web_contents_); |
| 40 web_contents_modal_dialog_manager->WillClose(this); | 40 web_contents_modal_dialog_manager->WillClose(this); |
| 41 close_count++; | 41 close_count++; |
| 42 } | 42 } |
| 43 virtual void FocusWebContentsModalDialog() {} | 43 virtual void FocusWebContentsModalDialog() {} |
| 44 virtual void PulseWebContentsModalDialog() {} | 44 virtual void PulseWebContentsModalDialog() {} |
| 45 virtual gfx::NativeWindow GetNativeWindow() { | 45 virtual gfx::NativeWindow GetNativeDialog() { |
| 46 NOTREACHED(); | 46 NOTREACHED(); |
| 47 return NULL; | 47 return NULL; |
| 48 } | 48 } |
| 49 virtual ~WebContentsModalDialogCloseTest() {} | 49 virtual ~WebContentsModalDialogCloseTest() {} |
| 50 | 50 |
| 51 int close_count; | 51 int close_count; |
| 52 content::WebContents* web_contents_; | 52 content::WebContents* web_contents_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 TEST_F(WebContentsModalDialogManagerTest, WebContentsModalDialogs) { | 55 TEST_F(WebContentsModalDialogManagerTest, WebContentsModalDialogs) { |
| 56 WebContentsModalDialogCloseTest window(web_contents()); | 56 WebContentsModalDialogCloseTest window(web_contents()); |
| 57 window.close_count = 0; | 57 window.close_count = 0; |
| 58 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 58 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 59 WebContentsModalDialogManager::FromWebContents(web_contents()); | 59 WebContentsModalDialogManager::FromWebContents(web_contents()); |
| 60 WebContentsModalDialogManager::TestApi test_api( | 60 WebContentsModalDialogManager::TestApi test_api( |
| 61 web_contents_modal_dialog_manager); | 61 web_contents_modal_dialog_manager); |
| 62 | 62 |
| 63 test_api.ResetNativeManager(NULL); | 63 test_api.ResetNativeManager(NULL); |
| 64 | 64 |
| 65 const int kWindowCount = 4; | 65 const int kWindowCount = 4; |
| 66 for (int i = 0; i < kWindowCount; i++) | 66 for (int i = 0; i < kWindowCount; i++) |
| 67 web_contents_modal_dialog_manager->AddDialog(&window); | 67 web_contents_modal_dialog_manager->AddDialog(&window); |
| 68 EXPECT_EQ(window.close_count, 0); | 68 EXPECT_EQ(window.close_count, 0); |
| 69 | 69 |
| 70 test_api.CloseAllDialogs(); | 70 test_api.CloseAllDialogs(); |
| 71 EXPECT_EQ(window.close_count, kWindowCount); | 71 EXPECT_EQ(window.close_count, kWindowCount); |
| 72 } | 72 } |
| OLD | NEW |