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.h" |
10 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser_tabstrip.h" |
12 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 13 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 class MockTabModalConfirmDialogDelegate : public TabModalConfirmDialogDelegate { | 18 class MockTabModalConfirmDialogDelegate : public TabModalConfirmDialogDelegate { |
18 public: | 19 public: |
19 explicit MockTabModalConfirmDialogDelegate(content::WebContents* web_contents) | 20 explicit MockTabModalConfirmDialogDelegate(content::WebContents* web_contents) |
20 : TabModalConfirmDialogDelegate(web_contents) {} | 21 : TabModalConfirmDialogDelegate(web_contents) {} |
21 | 22 |
(...skipping 10 matching lines...) Expand all Loading... |
32 private: | 33 private: |
33 DISALLOW_COPY_AND_ASSIGN(MockTabModalConfirmDialogDelegate); | 34 DISALLOW_COPY_AND_ASSIGN(MockTabModalConfirmDialogDelegate); |
34 }; | 35 }; |
35 | 36 |
36 TabModalConfirmDialogTest::TabModalConfirmDialogTest() | 37 TabModalConfirmDialogTest::TabModalConfirmDialogTest() |
37 : delegate_(NULL), | 38 : delegate_(NULL), |
38 dialog_(NULL) {} | 39 dialog_(NULL) {} |
39 | 40 |
40 void TabModalConfirmDialogTest::SetUpOnMainThread() { | 41 void TabModalConfirmDialogTest::SetUpOnMainThread() { |
41 delegate_ = new MockTabModalConfirmDialogDelegate( | 42 delegate_ = new MockTabModalConfirmDialogDelegate( |
42 browser()->GetActiveWebContents()); | 43 chrome::GetActiveWebContents(browser())); |
43 dialog_ = CreateTestDialog(delegate_, | 44 dialog_ = CreateTestDialog(delegate_, |
44 browser()->GetActiveTabContents()); | 45 chrome::GetActiveTabContents(browser())); |
45 ui_test_utils::RunAllPendingInMessageLoop(); | 46 ui_test_utils::RunAllPendingInMessageLoop(); |
46 } | 47 } |
47 | 48 |
48 void TabModalConfirmDialogTest::CleanUpOnMainThread() { | 49 void TabModalConfirmDialogTest::CleanUpOnMainThread() { |
49 ui_test_utils::RunAllPendingInMessageLoop(); | 50 ui_test_utils::RunAllPendingInMessageLoop(); |
50 ::testing::Mock::VerifyAndClearExpectations(delegate_); | 51 ::testing::Mock::VerifyAndClearExpectations(delegate_); |
51 } | 52 } |
52 | 53 |
53 // On Mac OS, these methods need to be compiled as Objective-C++, so they're in | 54 // On Mac OS, these methods need to be compiled as Objective-C++, so they're in |
54 // a separate file. | 55 // a separate file. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 EXPECT_CALL(*delegate_, OnCanceled()); | 88 EXPECT_CALL(*delegate_, OnCanceled()); |
88 delegate_->Cancel(); | 89 delegate_->Cancel(); |
89 } | 90 } |
90 | 91 |
91 IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Quit) { | 92 IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Quit) { |
92 EXPECT_CALL(*delegate_, OnCanceled()); | 93 EXPECT_CALL(*delegate_, OnCanceled()); |
93 MessageLoopForUI::current()->PostTask(FROM_HERE, | 94 MessageLoopForUI::current()->PostTask(FROM_HERE, |
94 base::Bind(&browser::AttemptExit)); | 95 base::Bind(&browser::AttemptExit)); |
95 ui_test_utils::RunMessageLoop(); | 96 ui_test_utils::RunMessageLoop(); |
96 } | 97 } |
OLD | NEW |