| 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/tab_modal_confirm_dialog_browsertest.h" | 5 #include "chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/lifetime/application_lifetime.h" | 9 #include "chrome/browser/lifetime/application_lifetime.h" |
| 10 #include "chrome/browser/ui/browser_dialogs.h" | 10 #include "chrome/browser/ui/browser_dialogs.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 private: | 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(MockTabModalConfirmDialogDelegate); | 33 DISALLOW_COPY_AND_ASSIGN(MockTabModalConfirmDialogDelegate); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 TabModalConfirmDialogTest::TabModalConfirmDialogTest() | 36 TabModalConfirmDialogTest::TabModalConfirmDialogTest() |
| 37 : delegate_(NULL), | 37 : delegate_(NULL), |
| 38 dialog_(NULL) {} | 38 dialog_(NULL) {} |
| 39 | 39 |
| 40 void TabModalConfirmDialogTest::SetUpOnMainThread() { | 40 void TabModalConfirmDialogTest::SetUpOnMainThread() { |
| 41 delegate_ = new MockTabModalConfirmDialogDelegate( | 41 delegate_ = new MockTabModalConfirmDialogDelegate( |
| 42 browser()->GetSelectedWebContents()); | 42 browser()->GetActiveWebContents()); |
| 43 dialog_ = CreateTestDialog(delegate_, | 43 dialog_ = CreateTestDialog(delegate_, |
| 44 browser()->GetSelectedTabContentsWrapper()); | 44 browser()->GetActiveTabContents()); |
| 45 ui_test_utils::RunAllPendingInMessageLoop(); | 45 ui_test_utils::RunAllPendingInMessageLoop(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void TabModalConfirmDialogTest::CleanUpOnMainThread() { | 48 void TabModalConfirmDialogTest::CleanUpOnMainThread() { |
| 49 ui_test_utils::RunAllPendingInMessageLoop(); | 49 ui_test_utils::RunAllPendingInMessageLoop(); |
| 50 ::testing::Mock::VerifyAndClearExpectations(delegate_); | 50 ::testing::Mock::VerifyAndClearExpectations(delegate_); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // On Mac OS, these methods need to be compiled as Objective-C++, so they're in | 53 // On Mac OS, these methods need to be compiled as Objective-C++, so they're in |
| 54 // a separate file. | 54 // a separate file. |
| 55 #if !defined(OS_MACOSX) | 55 #if !defined(OS_MACOSX) |
| 56 TabModalConfirmDialog* TabModalConfirmDialogTest::CreateTestDialog( | 56 TabModalConfirmDialog* TabModalConfirmDialogTest::CreateTestDialog( |
| 57 TabModalConfirmDialogDelegate* delegate, TabContentsWrapper* wrapper) { | 57 TabModalConfirmDialogDelegate* delegate, TabContents* tab_contents) { |
| 58 return new TabModalConfirmDialog(delegate, wrapper); | 58 return new TabModalConfirmDialog(delegate, tab_contents); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void TabModalConfirmDialogTest::CloseDialog(bool accept) { | 61 void TabModalConfirmDialogTest::CloseDialog(bool accept) { |
| 62 #if defined(TOOLKIT_GTK) | 62 #if defined(TOOLKIT_GTK) |
| 63 if (accept) | 63 if (accept) |
| 64 dialog_->OnAccept(NULL); | 64 dialog_->OnAccept(NULL); |
| 65 else | 65 else |
| 66 dialog_->OnCancel(NULL); | 66 dialog_->OnCancel(NULL); |
| 67 #else | 67 #else |
| 68 if (accept) | 68 if (accept) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 87 EXPECT_CALL(*delegate_, OnCanceled()); | 87 EXPECT_CALL(*delegate_, OnCanceled()); |
| 88 delegate_->Cancel(); | 88 delegate_->Cancel(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Quit) { | 91 IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Quit) { |
| 92 EXPECT_CALL(*delegate_, OnCanceled()); | 92 EXPECT_CALL(*delegate_, OnCanceled()); |
| 93 MessageLoopForUI::current()->PostTask(FROM_HERE, | 93 MessageLoopForUI::current()->PostTask(FROM_HERE, |
| 94 base::Bind(&browser::AttemptExit)); | 94 base::Bind(&browser::AttemptExit)); |
| 95 ui_test_utils::RunMessageLoop(); | 95 ui_test_utils::RunMessageLoop(); |
| 96 } | 96 } |
| OLD | NEW |