| Index: ui/views/window/dialog_delegate_unittest.cc
|
| diff --git a/ui/views/window/dialog_delegate_unittest.cc b/ui/views/window/dialog_delegate_unittest.cc
|
| index 3cfa8296917b2258f3f17807b560506bb6ad87f5..d11cfddde8f6aabf0595da8212e837a7e92e24b4 100644
|
| --- a/ui/views/window/dialog_delegate_unittest.cc
|
| +++ b/ui/views/window/dialog_delegate_unittest.cc
|
| @@ -28,7 +28,15 @@
|
|
|
| class TestDialog : public DialogDelegateView {
|
| public:
|
| - TestDialog() : input_(new views::Textfield()) { AddChildView(input_); }
|
| + TestDialog()
|
| + : input_(new views::Textfield()),
|
| + canceled_(false),
|
| + accepted_(false),
|
| + closed_(false),
|
| + closeable_(false),
|
| + should_handle_escape_(false) {
|
| + AddChildView(input_);
|
| + }
|
| ~TestDialog() override {}
|
|
|
| void Init() {
|
| @@ -43,7 +51,6 @@
|
| bool ShouldShowWindowTitle() const override {
|
| return !title_.empty();
|
| }
|
| - bool ShouldShowCloseButton() const override { return show_close_button_; }
|
|
|
| // DialogDelegateView overrides:
|
| bool Cancel() override {
|
| @@ -59,6 +66,7 @@
|
| return closeable_;
|
| }
|
|
|
| + // DialogDelegateView overrides:
|
| gfx::Size GetPreferredSize() const override { return gfx::Size(200, 200); }
|
| bool AcceleratorPressed(const ui::Accelerator& accelerator) override {
|
| return should_handle_escape_;
|
| @@ -84,9 +92,6 @@
|
| }
|
|
|
| void set_title(const base::string16& title) { title_ = title; }
|
| - void set_show_close_button(bool show_close) {
|
| - show_close_button_ = show_close;
|
| - }
|
| void set_should_handle_escape(bool should_handle_escape) {
|
| should_handle_escape_ = should_handle_escape;
|
| }
|
| @@ -95,14 +100,13 @@
|
|
|
| private:
|
| views::Textfield* input_;
|
| - bool canceled_ = false;
|
| - bool accepted_ = false;
|
| - bool closed_ = false;
|
| + bool canceled_;
|
| + bool accepted_;
|
| + bool closed_;
|
| // Prevent the dialog from closing, for repeated ok and cancel button clicks.
|
| bool closeable_;
|
| base::string16 title_;
|
| - bool show_close_button_ = true;
|
| - bool should_handle_escape_ = false;
|
| + bool should_handle_escape_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TestDialog);
|
| };
|
| @@ -114,25 +118,14 @@
|
|
|
| void SetUp() override {
|
| ViewsTestBase::SetUp();
|
| - InitializeDialog();
|
| - ShowDialog();
|
| + dialog_ = new TestDialog();
|
| + dialog_->Init();
|
| + DialogDelegate::CreateDialogWidget(dialog_, GetContext(), nullptr)->Show();
|
| }
|
|
|
| void TearDown() override {
|
| dialog_->TearDown();
|
| ViewsTestBase::TearDown();
|
| - }
|
| -
|
| - void InitializeDialog() {
|
| - if (dialog_)
|
| - dialog_->TearDown();
|
| -
|
| - dialog_ = new TestDialog();
|
| - dialog_->Init();
|
| - }
|
| -
|
| - void ShowDialog() {
|
| - DialogDelegate::CreateDialogWidget(dialog_, GetContext(), nullptr)->Show();
|
| }
|
|
|
| void SimulateKeyEvent(const ui::KeyEvent& event) {
|
| @@ -215,38 +208,12 @@
|
| const int point;
|
| const int hit;
|
| } cases[] = {
|
| - {border, HTSYSMENU},
|
| - {border + 10, HTSYSMENU},
|
| - {border + 20, HTNOWHERE},
|
| - {border + 50, HTCLIENT /* Space is reserved for the close button. */},
|
| - {border + 60, HTCLIENT},
|
| - {1000, HTNOWHERE},
|
| - };
|
| -
|
| - for (size_t i = 0; i < arraysize(cases); ++i) {
|
| - gfx::Point point(cases[i].point, cases[i].point);
|
| - EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point))
|
| - << " case " << i << " with border: " << border << ", at point "
|
| - << cases[i].point;
|
| - }
|
| -}
|
| -
|
| -TEST_F(DialogTest, HitTest_HiddenTitleNoCloseButton) {
|
| - InitializeDialog();
|
| - dialog()->set_show_close_button(false);
|
| - ShowDialog();
|
| -
|
| - const NonClientView* view = dialog()->GetWidget()->non_client_view();
|
| - BubbleFrameView* frame = static_cast<BubbleFrameView*>(view->frame_view());
|
| - const int border = frame->bubble_border()->GetBorderThickness();
|
| -
|
| - struct {
|
| - const int point;
|
| - const int hit;
|
| - } cases[] = {
|
| - {border, HTSYSMENU}, {border + 10, HTSYSMENU},
|
| - {border + 20, HTCLIENT}, {border + 50, HTCLIENT},
|
| - {border + 60, HTCLIENT}, {1000, HTNOWHERE},
|
| + { border, HTSYSMENU },
|
| + { border + 10, HTSYSMENU },
|
| + { border + 20, HTCLIENT },
|
| + { border + 50, HTCLIENT },
|
| + { border + 60, HTCLIENT },
|
| + { 1000, HTNOWHERE },
|
| };
|
|
|
| for (size_t i = 0; i < arraysize(cases); ++i) {
|
|
|