Commit dc037e9d authored by karandeepb's avatar karandeepb Committed by Commit bot

DialogDelegate unittests: Remove dead code.

This CL removes some dead code from dialog_delegate_unittest.cc. r206950 made
the TestDialog class a ButtonListener and added the last_pressed_button()
method. However r372427 removed the last usages of TestDialog as a
ButtonListener. This CL modifies TestDialog to not be a ButtonListener anymore
and removes the associated dead code.

BUG=NONE

Review-Url: https://codereview.chromium.org/2605273002
Cr-Commit-Position: refs/heads/master@{#440970}
parent 5181014d
...@@ -22,7 +22,7 @@ namespace views { ...@@ -22,7 +22,7 @@ namespace views {
namespace { namespace {
class TestDialog : public DialogDelegateView, public ButtonListener { class TestDialog : public DialogDelegateView {
public: public:
TestDialog() TestDialog()
: input_(new views::Textfield()), : input_(new views::Textfield()),
...@@ -30,7 +30,6 @@ class TestDialog : public DialogDelegateView, public ButtonListener { ...@@ -30,7 +30,6 @@ class TestDialog : public DialogDelegateView, public ButtonListener {
accepted_(false), accepted_(false),
closed_(false), closed_(false),
closeable_(false), closeable_(false),
last_pressed_button_(nullptr),
should_handle_escape_(false) { should_handle_escape_(false) {
AddChildView(input_); AddChildView(input_);
} }
...@@ -72,23 +71,13 @@ class TestDialog : public DialogDelegateView, public ButtonListener { ...@@ -72,23 +71,13 @@ class TestDialog : public DialogDelegateView, public ButtonListener {
View* GetInitiallyFocusedView() override { return input_; } View* GetInitiallyFocusedView() override { return input_; }
bool ShouldUseCustomFrame() const override { return true; } bool ShouldUseCustomFrame() const override { return true; }
// ButtonListener override:
void ButtonPressed(Button* sender, const ui::Event& event) override {
last_pressed_button_ = sender;
}
Button* last_pressed_button() const { return last_pressed_button_; }
void CheckAndResetStates(bool canceled, void CheckAndResetStates(bool canceled,
bool accepted, bool accepted,
bool closed, bool closed) {
Button* last_pressed) {
EXPECT_EQ(canceled, canceled_); EXPECT_EQ(canceled, canceled_);
canceled_ = false; canceled_ = false;
EXPECT_EQ(accepted, accepted_); EXPECT_EQ(accepted, accepted_);
accepted_ = false; accepted_ = false;
EXPECT_EQ(last_pressed, last_pressed_button_);
last_pressed_button_ = nullptr;
EXPECT_EQ(closed, closed_); EXPECT_EQ(closed, closed_);
closed_ = false; closed_ = false;
} }
...@@ -112,7 +101,6 @@ class TestDialog : public DialogDelegateView, public ButtonListener { ...@@ -112,7 +101,6 @@ class TestDialog : public DialogDelegateView, public ButtonListener {
bool closed_; bool closed_;
// Prevent the dialog from closing, for repeated ok and cancel button clicks. // Prevent the dialog from closing, for repeated ok and cancel button clicks.
bool closeable_; bool closeable_;
Button* last_pressed_button_;
base::string16 title_; base::string16 title_;
bool should_handle_escape_; bool should_handle_escape_;
...@@ -162,28 +150,28 @@ TEST_F(DialogTest, AcceptAndCancel) { ...@@ -162,28 +150,28 @@ TEST_F(DialogTest, AcceptAndCancel) {
const ui::KeyEvent return_event( const ui::KeyEvent return_event(
ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE); ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE);
SimulateKeyEvent(return_event); SimulateKeyEvent(return_event);
dialog()->CheckAndResetStates(false, true, false, nullptr); dialog()->CheckAndResetStates(false, true, false);
const ui::KeyEvent escape_event( const ui::KeyEvent escape_event(
ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE); ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE);
SimulateKeyEvent(escape_event); SimulateKeyEvent(escape_event);
dialog()->CheckAndResetStates(false, false, true, nullptr); dialog()->CheckAndResetStates(false, false, true);
// Check ok and cancel button behavior on a directed return key events. // Check ok and cancel button behavior on a directed return key events.
ok_button->OnKeyPressed(return_event); ok_button->OnKeyPressed(return_event);
dialog()->CheckAndResetStates(false, true, false, nullptr); dialog()->CheckAndResetStates(false, true, false);
cancel_button->OnKeyPressed(return_event); cancel_button->OnKeyPressed(return_event);
dialog()->CheckAndResetStates(true, false, false, nullptr); dialog()->CheckAndResetStates(true, false, false);
// Check that return accelerators cancel dialogs if cancel is focused. // Check that return accelerators cancel dialogs if cancel is focused.
cancel_button->RequestFocus(); cancel_button->RequestFocus();
EXPECT_EQ(cancel_button, dialog()->GetFocusManager()->GetFocusedView()); EXPECT_EQ(cancel_button, dialog()->GetFocusManager()->GetFocusedView());
SimulateKeyEvent(return_event); SimulateKeyEvent(return_event);
dialog()->CheckAndResetStates(true, false, false, nullptr); dialog()->CheckAndResetStates(true, false, false);
// Check that escape can be overridden. // Check that escape can be overridden.
dialog()->set_should_handle_escape(true); dialog()->set_should_handle_escape(true);
SimulateKeyEvent(escape_event); SimulateKeyEvent(escape_event);
dialog()->CheckAndResetStates(false, false, false, nullptr); dialog()->CheckAndResetStates(false, false, false);
} }
TEST_F(DialogTest, RemoveDefaultButton) { TEST_F(DialogTest, RemoveDefaultButton) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment