Skip to content

Commit

Permalink
Added test for checking split view tab's path
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Dec 20, 2024
1 parent e4b5445 commit fe5d4fa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions browser/ui/tabs/brave_tab_layout_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ inline constexpr int kHorizontalTabStripLeftMargin = 3;
// occupied by tab group underlines.
inline constexpr int kHorizontalTabVerticalSpacing = 4;

inline constexpr int kHorizontalSplitViewTabVerticalSpacing = 6;

// The height of the tab strip in horizontal mode.
int GetHorizontalTabStripHeight();

Expand Down
35 changes: 35 additions & 0 deletions browser/ui/views/frame/split_view_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@

#include "base/run_loop.h"
#include "brave/browser/ui/browser_commands.h"
#include "brave/browser/ui/tabs/brave_tab_layout_constants.h"
#include "brave/browser/ui/tabs/features.h"
#include "brave/browser/ui/tabs/split_view_browser_data.h"
#include "brave/browser/ui/views/brave_javascript_tab_modal_dialog_view_views.h"
#include "brave/browser/ui/views/frame/brave_browser_view.h"
#include "brave/browser/ui/views/frame/brave_contents_layout_manager.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/tabs/tab_style_views.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/common/javascript_dialog_type.h"
#include "content/public/test/browser_test.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"

class SplitViewBrowserTest : public InProcessBrowserTest {
public:
Expand Down Expand Up @@ -227,3 +236,29 @@ IN_PROC_BROWSER_TEST_F(

EXPECT_EQ(web_view_bounds.CenterPoint().x(), dialog_bounds.CenterPoint().x());
}

IN_PROC_BROWSER_TEST_F(SplitViewBrowserTest, SplitViewTabPathTest) {
brave::NewSplitViewForTab(browser());
int active_index = tab_strip_model().active_index();
ASSERT_NE(TabStripModel::kNoTab, active_index);

TabStrip* tab_strip = browser_view().tabstrip();
Tab* tab = tab_strip->tab_at(active_index);

SkPath mask = tab->tab_style_views()->GetPath(TabStyle::PathType::kFill,
/* scale */ 1.0,
/* force_active */ false,
TabStyle::RenderUnits::kDips);
SkRegion clip_region;
clip_region.setRect({0, 0, 200, 200});
SkRegion mask_region;
ASSERT_TRUE(mask_region.setPath(mask, clip_region));

EXPECT_EQ(brave_tabs::kHorizontalSplitViewTabVerticalSpacing,
mask_region.getBounds().top());
EXPECT_EQ(brave_tabs::kHorizontalTabInset, mask_region.getBounds().left());
EXPECT_EQ(GetLayoutConstant(TAB_STRIP_HEIGHT) -
GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) -
(brave_tabs::kHorizontalSplitViewTabVerticalSpacing * 2),
mask_region.getBounds().height());
}
4 changes: 2 additions & 2 deletions browser/ui/views/tabs/brave_tab_style_views.inc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ SkPath BraveVerticalTabStyle::GetPath(
tab_left += scale * kPaddingForVerticalTabInTile;
tab_right -= scale * kPaddingForVerticalTabInTile;
} else {
constexpr int kTotalVerticalPaddingForHorizontalTab = 6;
constexpr int kAdditionalVerticalPadding =
kTotalVerticalPaddingForHorizontalTab - brave_tabs::kHorizontalTabGap;
brave_tabs::kHorizontalSplitViewTabVerticalSpacing -
brave_tabs::kHorizontalTabGap;
tab_top += scale * kAdditionalVerticalPadding;
tab_bottom -= scale * kAdditionalVerticalPadding;

Expand Down

0 comments on commit fe5d4fa

Please sign in to comment.