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

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_unittest.cc

Issue 2775083002: Update conditional in BrowserNonClientFrameView::DoesIntersectRect. (Closed)
Patch Set: edit comments 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/frame/browser_non_client_frame_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/ui/views/frame/browser_view.h" 8 #include "chrome/browser/ui/views/frame/browser_view.h"
9 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" 9 #include "chrome/browser/ui/views/frame/test_with_browser_view.h"
10 #include "chrome/browser/ui/views/tabs/tab_strip.h"
10 #include "ui/base/ui_base_switches.h" 11 #include "ui/base/ui_base_switches.h"
11 #include "url/gurl.h" 12 #include "url/gurl.h"
12 13
13 class BrowserNonClientFrameViewTest : public TestWithBrowserView { 14 class BrowserNonClientFrameViewTest : public TestWithBrowserView {
14 public: 15 public:
15 BrowserNonClientFrameViewTest() 16 explicit BrowserNonClientFrameViewTest(Browser::Type type)
16 : TestWithBrowserView(Browser::TYPE_POPUP, false), frame_view_(nullptr) {} 17 : TestWithBrowserView(type, false), frame_view_(nullptr) {}
17 18
18 // TestWithBrowserView override: 19 // TestWithBrowserView override:
19 void SetUp() override { 20 void SetUp() override {
20 #if defined(OS_WIN) 21 #if defined(OS_WIN)
21 // Use opaque frame. 22 // Use opaque frame.
22 base::CommandLine::ForCurrentProcess()->AppendSwitch( 23 base::CommandLine::ForCurrentProcess()->AppendSwitch(
23 switches::kDisableDwmComposition); 24 switches::kDisableDwmComposition);
24 #endif 25 #endif
25 TestWithBrowserView::SetUp(); 26 TestWithBrowserView::SetUp();
26 views::Widget* widget = browser_view()->GetWidget(); 27 views::Widget* widget = browser_view()->GetWidget();
27 frame_view_ = static_cast<BrowserNonClientFrameView*>( 28 frame_view_ = static_cast<BrowserNonClientFrameView*>(
28 widget->non_client_view()->frame_view()); 29 widget->non_client_view()->frame_view());
29 } 30 }
30 31
31 protected: 32 protected:
32 // Owned by the browser view. 33 // Owned by the browser view.
33 BrowserNonClientFrameView* frame_view_; 34 BrowserNonClientFrameView* frame_view_;
34 35
35 private: 36 private:
36 DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewTest); 37 DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewTest);
37 }; 38 };
38 39
39 TEST_F(BrowserNonClientFrameViewTest, HitTestTopChrome) { 40 class BrowserNonClientFrameViewPopupTest
41 : public BrowserNonClientFrameViewTest {
42 public:
43 BrowserNonClientFrameViewPopupTest()
44 : BrowserNonClientFrameViewTest(Browser::TYPE_POPUP) {}
45 };
46
47 TEST_F(BrowserNonClientFrameViewPopupTest, HitTestPopupTopChrome) {
40 EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(-1, 4, 1, 1))); 48 EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(-1, 4, 1, 1)));
41 EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(4, -1, 1, 1))); 49 EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(4, -1, 1, 1)));
42 const int top_inset = frame_view_->GetTopInset(false); 50 const int top_inset = frame_view_->GetTopInset(false);
43 EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(4, top_inset, 1, 1))); 51 EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(4, top_inset, 1, 1)));
44 if (top_inset > 0) 52 if (top_inset > 0)
45 EXPECT_TRUE(frame_view_->HitTestRect(gfx::Rect(4, top_inset - 1, 1, 1))); 53 EXPECT_TRUE(frame_view_->HitTestRect(gfx::Rect(4, top_inset - 1, 1, 1)));
46 } 54 }
55
56 class BrowserNonClientFrameViewTabbedTest
57 : public BrowserNonClientFrameViewTest {
58 public:
59 BrowserNonClientFrameViewTabbedTest()
60 : BrowserNonClientFrameViewTest(Browser::TYPE_TABBED) {}
61 };
62
63 TEST_F(BrowserNonClientFrameViewTabbedTest, HitTestTabstrip) {
64 gfx::Rect tabstrip_bounds =
65 frame_view_->browser_view()->tabstrip()->GetLocalBounds();
66 EXPECT_FALSE(tabstrip_bounds.IsEmpty());
67
68 // Completely outside bounds.
69 EXPECT_FALSE(frame_view_->HitTestRect(
70 gfx::Rect(tabstrip_bounds.x() - 1, tabstrip_bounds.y() + 1, 1, 1)));
71 EXPECT_FALSE(frame_view_->HitTestRect(
72 gfx::Rect(tabstrip_bounds.x() + 1, tabstrip_bounds.y() - 1, 1, 1)));
73
74 // Hits tab strip but not client area.
75 EXPECT_TRUE(frame_view_->HitTestRect(
76 gfx::Rect(tabstrip_bounds.x() + 1, tabstrip_bounds.bottom() - 1, 1, 1)));
77
78 // Hits tab strip and client area.
79 EXPECT_TRUE(frame_view_->HitTestRect(gfx::Rect(
80 tabstrip_bounds.x() + 1, tabstrip_bounds.bottom() - 1, 100, 100)));
81 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_non_client_frame_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698