| 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/strings/utf_string_conversions.h" | 8 #include "base/strings/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.h" |
| 11 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 MockTabModalConfirmDialogDelegate::MockTabModalConfirmDialogDelegate( | 16 MockTabModalConfirmDialogDelegate::MockTabModalConfirmDialogDelegate( |
| 17 content::WebContents* web_contents, | |
| 18 Delegate* delegate) | 17 Delegate* delegate) |
| 19 : TabModalConfirmDialogDelegate(web_contents), | 18 : delegate_(delegate) { |
| 20 delegate_(delegate) { | |
| 21 } | 19 } |
| 22 | 20 |
| 23 MockTabModalConfirmDialogDelegate::~MockTabModalConfirmDialogDelegate() { | 21 MockTabModalConfirmDialogDelegate::~MockTabModalConfirmDialogDelegate() { |
| 24 } | 22 } |
| 25 | 23 |
| 26 string16 MockTabModalConfirmDialogDelegate::GetTitle() { | 24 string16 MockTabModalConfirmDialogDelegate::GetTitle() { |
| 27 return string16(); | 25 return string16(); |
| 28 } | 26 } |
| 29 | 27 |
| 30 string16 MockTabModalConfirmDialogDelegate::GetMessage() { | 28 string16 MockTabModalConfirmDialogDelegate::GetMessage() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 42 } | 40 } |
| 43 | 41 |
| 44 TabModalConfirmDialogTest::TabModalConfirmDialogTest() | 42 TabModalConfirmDialogTest::TabModalConfirmDialogTest() |
| 45 : delegate_(NULL), | 43 : delegate_(NULL), |
| 46 dialog_(NULL), | 44 dialog_(NULL), |
| 47 accepted_count_(0), | 45 accepted_count_(0), |
| 48 canceled_count_(0) { | 46 canceled_count_(0) { |
| 49 } | 47 } |
| 50 | 48 |
| 51 void TabModalConfirmDialogTest::SetUpOnMainThread() { | 49 void TabModalConfirmDialogTest::SetUpOnMainThread() { |
| 52 delegate_ = new MockTabModalConfirmDialogDelegate( | 50 delegate_ = new MockTabModalConfirmDialogDelegate(this); |
| 53 browser()->tab_strip_model()->GetActiveWebContents(), this); | |
| 54 dialog_ = TabModalConfirmDialog::Create( | 51 dialog_ = TabModalConfirmDialog::Create( |
| 55 delegate_, browser()->tab_strip_model()->GetActiveWebContents()); | 52 delegate_, browser()->tab_strip_model()->GetActiveWebContents()); |
| 56 content::RunAllPendingInMessageLoop(); | 53 content::RunAllPendingInMessageLoop(); |
| 57 } | 54 } |
| 58 | 55 |
| 59 void TabModalConfirmDialogTest::CleanUpOnMainThread() { | 56 void TabModalConfirmDialogTest::CleanUpOnMainThread() { |
| 60 content::RunAllPendingInMessageLoop(); | 57 content::RunAllPendingInMessageLoop(); |
| 61 } | 58 } |
| 62 | 59 |
| 63 void TabModalConfirmDialogTest::OnAccepted() { | 60 void TabModalConfirmDialogTest::OnAccepted() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 86 EXPECT_EQ(1, canceled_count_); | 83 EXPECT_EQ(1, canceled_count_); |
| 87 } | 84 } |
| 88 | 85 |
| 89 IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Quit) { | 86 IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Quit) { |
| 90 base::MessageLoopForUI::current()->PostTask(FROM_HERE, | 87 base::MessageLoopForUI::current()->PostTask(FROM_HERE, |
| 91 base::Bind(&chrome::AttemptExit)); | 88 base::Bind(&chrome::AttemptExit)); |
| 92 content::RunMessageLoop(); | 89 content::RunMessageLoop(); |
| 93 EXPECT_EQ(0, accepted_count_); | 90 EXPECT_EQ(0, accepted_count_); |
| 94 EXPECT_EQ(1, canceled_count_); | 91 EXPECT_EQ(1, canceled_count_); |
| 95 } | 92 } |
| OLD | NEW |