Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: ui/views/window/dialog_delegate_unittest.cc

Issue 2821463004: Revert of Fix layout of BubbleFrameView when there's only a close button in the (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/bubble/bubble_frame_view_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « ui/views/bubble/bubble_frame_view_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698