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

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

Issue 15894025: Fix Views new dialog style hit-testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Aura context, simplify and make test more flexible. Created 7 years, 7 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/views.gyp ('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
new file mode 100644
index 0000000000000000000000000000000000000000..aac4e3dfe0f27da51178105ae88faf278fd3783d
--- /dev/null
+++ b/ui/views/window/dialog_delegate_unittest.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/hit_test.h"
+#include "ui/views/bubble/bubble_border.h"
+#include "ui/views/bubble/bubble_frame_view.h"
+#include "ui/views/test/views_test_base.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/window/dialog_delegate.h"
+
+namespace views {
+
+typedef ViewsTestBase DialogTest;
+
+namespace {
+
+class TestDialog : public DialogDelegateView {
+ public:
+ TestDialog() : can_resize_(false) {}
+ virtual ~TestDialog() {}
+
+ // BubbleDelegateView overrides:
+ virtual gfx::Size GetPreferredSize() OVERRIDE { return gfx::Size(200, 200); }
+ virtual bool CanResize() const OVERRIDE { return can_resize_; }
+
+ void set_can_resize(bool can_resize) { can_resize_ = can_resize; }
+
+ private:
+ bool can_resize_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestDialog);
+};
+
+} // namespace
+
+TEST_F(DialogTest, HitTest) {
+ TestDialog* dialog = new TestDialog();
+ DialogDelegate::CreateDialogWidget(dialog, NULL, GetContext());
+ const NonClientView* view = dialog->GetWidget()->non_client_view();
+
+ if (DialogDelegate::UseNewStyle()) {
+ // Ensure that the new style's BubbleFrameView hit-tests as expected.
+ BubbleFrameView* frame = static_cast<BubbleFrameView*>(view->frame_view());
+ const int border = frame->bubble_border()->GetBorderThickness();
+
+ struct {
+ const int point;
+ const int cannot_resize_hit;
+ const int can_resize_hit;
+ } cases[] = {
+ { border, HTSYSMENU, HTTOPLEFT },
+ { border + 3, HTSYSMENU, HTTOPLEFT },
+ { border + 4, HTSYSMENU, HTSYSMENU },
+ { border + 11, HTSYSMENU, HTSYSMENU },
+ { border + 12, HTCAPTION, HTCAPTION },
+ { border + 30, HTCAPTION, HTCAPTION },
+ { border + 40, HTCLIENT, HTCLIENT },
+ { border + 50, HTCLIENT, HTCLIENT },
+ { 1000, HTNOWHERE, HTNOWHERE },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ gfx::Point point(cases[i].point, cases[i].point);
+ dialog->set_can_resize(false);
+ EXPECT_EQ(cases[i].cannot_resize_hit, frame->NonClientHitTest(point))
+ << " with border: " << border << ", at point " << cases[i].point;
+ dialog->set_can_resize(true);
+ EXPECT_EQ(cases[i].can_resize_hit, frame->NonClientHitTest(point))
+ << " with border: " << border << ", at point " << cases[i].point;
+ }
+ }
+}
+
+} // namespace views
« no previous file with comments | « ui/views/views.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698