summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/view_unittest.cc32
1 files changed, 27 insertions, 5 deletions
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index f2309108..5dfc84d 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -1055,7 +1055,18 @@ class TestDialog : public DialogDelegate, public ButtonListener {
last_pressed_button_(NULL),
mock_menu_model_(mock_menu_model),
canceled_(false),
- oked_(false) {
+ oked_(false),
+ closeable_(false),
+ widget_(NULL) {
+ }
+
+ void TearDown() {
+ // Now we can close safely.
+ closeable_ = true;
+ widget_->Close();
+ widget_ = NULL;
+ // delegate has to be alive while shutting down.
+ MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
// DialogDelegate implementation:
@@ -1082,11 +1093,11 @@ class TestDialog : public DialogDelegate, public ButtonListener {
// buttons to our heart's content).
virtual bool Cancel() OVERRIDE {
canceled_ = true;
- return false;
+ return closeable_;
}
virtual bool Accept() OVERRIDE {
oked_ = true;
- return false;
+ return closeable_;
}
virtual Widget* GetWidget() OVERRIDE {
@@ -1128,6 +1139,7 @@ class TestDialog : public DialogDelegate, public ButtonListener {
bool canceled_;
bool oked_;
+ bool closeable_;
Widget* widget_;
};
@@ -1148,7 +1160,7 @@ class DefaultButtonTest : public ViewTest {
cancel_button_(NULL) {
}
- virtual void SetUp() {
+ virtual void SetUp() OVERRIDE {
test_dialog_ = new TestDialog(NULL);
Widget* window =
Widget::CreateWindowWithBounds(test_dialog_, gfx::Rect(0, 0, 100, 100));
@@ -1162,6 +1174,11 @@ class DefaultButtonTest : public ViewTest {
cancel_button_ = client_view_->cancel_button();
}
+ virtual void TearDown() OVERRIDE {
+ test_dialog_->TearDown();
+ ViewTest::TearDown();
+ }
+
void SimulatePressingEnterAndCheckDefaultButton(ButtonID button_id) {
KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0);
focus_manager_->OnKeyEvent(event);
@@ -1253,7 +1270,7 @@ class ButtonDropDownTest : public ViewTest {
button_as_view_(NULL) {
}
- virtual void SetUp() {
+ virtual void SetUp() OVERRIDE {
test_dialog_ = new TestDialog(&mock_menu_model_);
Widget* window =
Widget::CreateWindowWithBounds(test_dialog_, gfx::Rect(0, 0, 100, 100));
@@ -1265,6 +1282,11 @@ class ButtonDropDownTest : public ViewTest {
button_as_view_ = static_cast<View*>(test_dialog_->button_drop_);
}
+ virtual void TearDown() OVERRIDE {
+ test_dialog_->TearDown();
+ ViewTest::TearDown();
+ }
+
TestDialog* test_dialog_;
MockMenuModel mock_menu_model_;
// This is owned by test_dialog_.