Commit 1750ad04 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Removed browser dependency in browser_view_layout

Factored out the browser dependency present in browser_view_layout by
moving the required functionality to its delegate, allowing for
simplified testing of the layout component.

Bug: 871419
Change-Id: If4d738677ad1e6666cda245e64aa62a2e2d103ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877613
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710046}
parent b5a07976
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window_state.h" #include "chrome/browser/ui/browser_window_state.h"
#include "chrome/browser/ui/find_bar/find_bar.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/in_product_help/reopen_tab_in_product_help.h" #include "chrome/browser/ui/in_product_help/reopen_tab_in_product_help.h"
#include "chrome/browser/ui/in_product_help/reopen_tab_in_product_help_factory.h" #include "chrome/browser/ui/in_product_help/reopen_tab_in_product_help_factory.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
...@@ -376,6 +378,27 @@ class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate { ...@@ -376,6 +378,27 @@ class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate {
return browser_view_->GetTopControlsSlideBehaviorShownRatio(); return browser_view_->GetTopControlsSlideBehaviorShownRatio();
} }
bool SupportsWindowFeature(Browser::WindowFeature feature) const override {
return browser_view_->browser()->SupportsWindowFeature(feature);
}
gfx::NativeView GetHostView() const override {
return browser_view_->GetWidget()->GetNativeView();
}
bool BrowserIsTypeNormal() const override {
return browser_view_->browser()->is_type_normal();
}
bool HasFindBarController() const override {
return browser_view_->browser()->HasFindBarController();
}
void MoveWindowForFindBarIfNecessary() const override {
auto* const controller = browser_view_->browser()->GetFindBarController();
return controller->find_bar()->MoveWindowIfNecessary();
}
private: private:
BrowserView* browser_view_; BrowserView* browser_view_;
...@@ -2597,11 +2620,11 @@ void BrowserView::InitViews() { ...@@ -2597,11 +2620,11 @@ void BrowserView::InitViews() {
} }
auto browser_view_layout = std::make_unique<BrowserViewLayout>( auto browser_view_layout = std::make_unique<BrowserViewLayout>(
std::make_unique<BrowserViewLayoutDelegateImpl>(this), browser(), this, std::make_unique<BrowserViewLayoutDelegateImpl>(this),
top_container_, tab_strip_region_view_, tabstrip_, webui_tab_strip_view, GetWidget()->GetNativeView(), this, top_container_,
toolbar_, infobar_container_, contents_container_, tab_strip_region_view_, tabstrip_, webui_tab_strip_view, toolbar_,
immersive_mode_controller_.get(), web_footer_experiment, infobar_container_, contents_container_, immersive_mode_controller_.get(),
contents_separator_); web_footer_experiment, contents_separator_);
SetLayoutManager(std::move(browser_view_layout)); SetLayoutManager(std::move(browser_view_layout));
EnsureFocusOrder(); EnsureFocusOrder();
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h" #include "chrome/browser/ui/views/download/download_shelf_view.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views.h" #include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
#include "chrome/browser/ui/views/frame/contents_layout_manager.h" #include "chrome/browser/ui/views/frame/contents_layout_manager.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
...@@ -91,10 +90,6 @@ class BrowserViewLayout::WebContentsModalDialogHostViews ...@@ -91,10 +90,6 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
return gfx::Point(middle_x - size.width() / 2, top); return gfx::Point(middle_x - size.width() / 2, top);
} }
bool ShouldActivateDialog() const override {
return chrome::FindLastActive() == browser_view_layout_->browser_;
}
gfx::Size GetMaximumDialogSize() override { gfx::Size GetMaximumDialogSize() override {
views::View* view = browser_view_layout_->contents_container_; views::View* view = browser_view_layout_->contents_container_;
gfx::Rect content_area = view->ConvertRectToWidget(view->GetLocalBounds()); gfx::Rect content_area = view->ConvertRectToWidget(view->GetLocalBounds());
...@@ -104,9 +99,7 @@ class BrowserViewLayout::WebContentsModalDialogHostViews ...@@ -104,9 +99,7 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
private: private:
gfx::NativeView GetHostView() const override { gfx::NativeView GetHostView() const override {
gfx::NativeWindow window = return browser_view_layout_->host_view_;
browser_view_layout_->browser()->window()->GetNativeWindow();
return views::Widget::GetWidgetForNativeWindow(window)->GetNativeView();
} }
// Add/remove observer. // Add/remove observer.
...@@ -129,8 +122,8 @@ class BrowserViewLayout::WebContentsModalDialogHostViews ...@@ -129,8 +122,8 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
BrowserViewLayout::BrowserViewLayout( BrowserViewLayout::BrowserViewLayout(
std::unique_ptr<BrowserViewLayoutDelegate> delegate, std::unique_ptr<BrowserViewLayoutDelegate> delegate,
Browser* browser, gfx::NativeView host_view,
views::ClientView* browser_view, BrowserView* browser_view,
views::View* top_container, views::View* top_container,
views::View* tab_strip_region_view, views::View* tab_strip_region_view,
TabStrip* tab_strip, TabStrip* tab_strip,
...@@ -142,7 +135,7 @@ BrowserViewLayout::BrowserViewLayout( ...@@ -142,7 +135,7 @@ BrowserViewLayout::BrowserViewLayout(
views::View* web_footer_experiment, views::View* web_footer_experiment,
views::View* contents_separator) views::View* contents_separator)
: delegate_(std::move(delegate)), : delegate_(std::move(delegate)),
browser_(browser), host_view_(host_view),
browser_view_(browser_view), browser_view_(browser_view),
top_container_(top_container), top_container_(top_container),
tab_strip_region_view_(tab_strip_region_view), tab_strip_region_view_(tab_strip_region_view),
...@@ -175,14 +168,14 @@ gfx::Size BrowserViewLayout::GetMinimumSize(const views::View* host) const { ...@@ -175,14 +168,14 @@ gfx::Size BrowserViewLayout::GetMinimumSize(const views::View* host) const {
constexpr int kMainBrowserContentsMinimumHeight = 1; constexpr int kMainBrowserContentsMinimumHeight = 1;
const bool has_tabstrip = const bool has_tabstrip =
browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); delegate_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
const bool has_toolbar = const bool has_toolbar =
browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR); delegate_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR);
const bool has_location_bar = const bool has_location_bar =
browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); delegate_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
const bool has_bookmarks_bar = const bool has_bookmarks_bar =
bookmark_bar_ && bookmark_bar_->GetVisible() && bookmark_bar_ && bookmark_bar_->GetVisible() &&
browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); delegate_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR);
gfx::Size tabstrip_size(has_tabstrip ? tab_strip_->GetMinimumSize() gfx::Size tabstrip_size(has_tabstrip ? tab_strip_->GetMinimumSize()
: gfx::Size()); : gfx::Size());
...@@ -196,7 +189,7 @@ gfx::Size BrowserViewLayout::GetMinimumSize(const views::View* host) const { ...@@ -196,7 +189,7 @@ gfx::Size BrowserViewLayout::GetMinimumSize(const views::View* host) const {
// TODO(pkotwicz): Adjust the minimum height for the find bar. // TODO(pkotwicz): Adjust the minimum height for the find bar.
gfx::Size contents_size(contents_container_->GetMinimumSize()); gfx::Size contents_size(contents_container_->GetMinimumSize());
contents_size.SetToMax(browser()->is_type_normal() contents_size.SetToMax(delegate_->BrowserIsTypeNormal()
? gfx::Size(kMainBrowserContentsMinimumWidth, ? gfx::Size(kMainBrowserContentsMinimumWidth,
kMainBrowserContentsMinimumHeight) kMainBrowserContentsMinimumHeight)
: kContentsMinimumSize); : kContentsMinimumSize);
...@@ -224,14 +217,11 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { ...@@ -224,14 +217,11 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const {
// The "user-perceived content area" excludes the detached bookmark bar (in // The "user-perceived content area" excludes the detached bookmark bar (in
// the New Tab case) and any infobars since they are not _visually_ connected // the New Tab case) and any infobars since they are not _visually_ connected
// to the Toolbar. // to the Toolbar.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
gfx::Rect bounding_box; gfx::Rect bounding_box;
if (!immersive_mode_controller_->IsEnabled() || if (!immersive_mode_controller_->IsEnabled() ||
immersive_mode_controller_->IsRevealed()) { immersive_mode_controller_->IsRevealed()) {
bounding_box = bounding_box =
browser_view->toolbar_button_provider()->GetFindBarBoundingBox( browser_view_->toolbar_button_provider()->GetFindBarBoundingBox(
contents_container_->height()); contents_container_->height());
} }
if (!bounding_box.IsEmpty()) if (!bounding_box.IsEmpty())
...@@ -244,9 +234,9 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { ...@@ -244,9 +234,9 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const {
// Under ChromeOS, the top_container_ may include the title bar for hosted // Under ChromeOS, the top_container_ may include the title bar for hosted
// apps. Just make sure something of consequence is visible before it's height // apps. Just make sure something of consequence is visible before it's height
// is used. // is used.
const int top_container_height = (browser_view->tabstrip()->GetVisible() || const int top_container_height = (browser_view_->tabstrip()->GetVisible() ||
browser_view->toolbar()->GetVisible() || browser_view_->toolbar()->GetVisible() ||
browser_view->IsBookmarkBarVisible()) browser_view_->IsBookmarkBarVisible())
? top_container_->height() ? top_container_->height()
: 0; : 0;
if (base::i18n::IsRTL()) if (base::i18n::IsRTL())
...@@ -256,6 +246,10 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { ...@@ -256,6 +246,10 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const {
return bounding_box; return bounding_box;
} }
gfx::NativeView BrowserViewLayout::GetHostView() {
return delegate_->GetHostView();
}
int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) { int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) {
// Since the TabStrip only renders in some parts of the top of the window, // Since the TabStrip only renders in some parts of the top of the window,
// the un-obscured area is considered to be part of the non-client caption // the un-obscured area is considered to be part of the non-client caption
...@@ -359,8 +353,8 @@ void BrowserViewLayout::Layout(views::View* browser_view) { ...@@ -359,8 +353,8 @@ void BrowserViewLayout::Layout(views::View* browser_view) {
// code calls back into us to find the bounding box the find bar // code calls back into us to find the bounding box the find bar
// must be laid out within, and that code depends on the // must be laid out within, and that code depends on the
// TabContentsContainer's bounds being up to date. // TabContentsContainer's bounds being up to date.
if (browser()->HasFindBarController()) if (delegate_->HasFindBarController())
browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary(); delegate_->MoveWindowForFindBarIfNecessary();
// Adjust the fullscreen exit bubble bounds for |top_container_|'s new bounds. // Adjust the fullscreen exit bubble bounds for |top_container_|'s new bounds.
// This makes the fullscreen exit bubble look like it animates with // This makes the fullscreen exit bubble look like it animates with
...@@ -533,8 +527,8 @@ void BrowserViewLayout::UpdateTopContainerBounds() { ...@@ -533,8 +527,8 @@ void BrowserViewLayout::UpdateTopContainerBounds() {
int BrowserViewLayout::LayoutDownloadShelf(int bottom) { int BrowserViewLayout::LayoutDownloadShelf(int bottom) {
if (delegate_->DownloadShelfNeedsLayout()) { if (delegate_->DownloadShelfNeedsLayout()) {
bool visible = browser()->SupportsWindowFeature( bool visible =
Browser::FEATURE_DOWNLOADSHELF); delegate_->SupportsWindowFeature(Browser::FEATURE_DOWNLOADSHELF);
DCHECK(download_shelf_); DCHECK(download_shelf_);
int height = visible ? download_shelf_->GetPreferredSize().height() : 0; int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
download_shelf_->SetVisible(visible); download_shelf_->SetVisible(visible);
...@@ -567,6 +561,6 @@ bool BrowserViewLayout::IsInfobarVisible() const { ...@@ -567,6 +561,6 @@ bool BrowserViewLayout::IsInfobarVisible() const {
// Cast to a views::View to access GetPreferredSize(). // Cast to a views::View to access GetPreferredSize().
views::View* infobar_container = infobar_container_; views::View* infobar_container = infobar_container_;
// NOTE: Can't check if the size IsEmpty() since it's always 0-width. // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && return delegate_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
(infobar_container->GetPreferredSize().height() != 0); (infobar_container->GetPreferredSize().height() != 0);
} }
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
#include "base/macros.h" #include "base/macros.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/layout/layout_manager.h" #include "ui/views/layout/layout_manager.h"
class BookmarkBarView; class BookmarkBarView;
class Browser; class BrowserView;
class BrowserViewLayoutDelegate; class BrowserViewLayoutDelegate;
class ImmersiveModeController; class ImmersiveModeController;
class InfoBarContainerView; class InfoBarContainerView;
...@@ -26,7 +27,6 @@ class Point; ...@@ -26,7 +27,6 @@ class Point;
} // namespace gfx } // namespace gfx
namespace views { namespace views {
class ClientView;
class View; class View;
class Widget; class Widget;
} // namespace views } // namespace views
...@@ -49,8 +49,8 @@ class BrowserViewLayout : public views::LayoutManager { ...@@ -49,8 +49,8 @@ class BrowserViewLayout : public views::LayoutManager {
// |browser_view| may be null in tests. // |browser_view| may be null in tests.
BrowserViewLayout(std::unique_ptr<BrowserViewLayoutDelegate> delegate, BrowserViewLayout(std::unique_ptr<BrowserViewLayoutDelegate> delegate,
Browser* browser, gfx::NativeView host_view,
views::ClientView* browser_view, BrowserView* browser_view,
views::View* top_container, views::View* top_container,
views::View* tab_strip_region_view, views::View* tab_strip_region_view,
TabStrip* tab_strip, TabStrip* tab_strip,
...@@ -81,6 +81,9 @@ class BrowserViewLayout : public views::LayoutManager { ...@@ -81,6 +81,9 @@ class BrowserViewLayout : public views::LayoutManager {
// Returns the bounding box, in widget coordinates, for the find bar. // Returns the bounding box, in widget coordinates, for the find bar.
gfx::Rect GetFindBarBoundingBox() const; gfx::Rect GetFindBarBoundingBox() const;
// Returns the view against which the dialog is positioned and parented.
gfx::NativeView GetHostView();
// Tests to see if the specified |point| (in nonclient view's coordinates) // Tests to see if the specified |point| (in nonclient view's coordinates)
// is within the views managed by the laymanager. Returns one of // is within the views managed by the laymanager. Returns one of
// HitTestCompat enum defined in ui/base/hit_test.h. // HitTestCompat enum defined in ui/base/hit_test.h.
...@@ -101,9 +104,6 @@ class BrowserViewLayout : public views::LayoutManager { ...@@ -101,9 +104,6 @@ class BrowserViewLayout : public views::LayoutManager {
FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, LayoutDownloadShelf); FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, LayoutDownloadShelf);
class WebContentsModalDialogHostViews; class WebContentsModalDialogHostViews;
Browser* browser() { return browser_; }
const Browser* browser() const { return browser_; }
// Layout the following controls, starting at |top|, returns the coordinate // Layout the following controls, starting at |top|, returns the coordinate
// of the bottom of the control, for laying out the next control. // of the bottom of the control, for laying out the next control.
int LayoutTabStripRegion(int top); int LayoutTabStripRegion(int top);
...@@ -136,11 +136,11 @@ class BrowserViewLayout : public views::LayoutManager { ...@@ -136,11 +136,11 @@ class BrowserViewLayout : public views::LayoutManager {
// The delegate interface. May be a mock in tests. // The delegate interface. May be a mock in tests.
const std::unique_ptr<BrowserViewLayoutDelegate> delegate_; const std::unique_ptr<BrowserViewLayoutDelegate> delegate_;
// The browser from the owning BrowserView. // The view against which the web dialog is positioned and parented.
Browser* const browser_; gfx::NativeView const host_view_;
// The owning browser view. // The owning browser view.
views::ClientView* const browser_view_; BrowserView* const browser_view_;
// Child views that the layout manager manages. // Child views that the layout manager manages.
// NOTE: If you add a view, try to add it as a views::View, which makes // NOTE: If you add a view, try to add it as a views::View, which makes
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_DELEGATE_H_ #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_DELEGATE_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_DELEGATE_H_ #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_DELEGATE_H_
#include "ui/gfx/native_widget_types.h"
class ExclusiveAccessBubbleViews; class ExclusiveAccessBubbleViews;
namespace gfx { namespace gfx {
...@@ -27,6 +29,11 @@ class BrowserViewLayoutDelegate { ...@@ -27,6 +29,11 @@ class BrowserViewLayoutDelegate {
virtual ExclusiveAccessBubbleViews* GetExclusiveAccessBubble() const = 0; virtual ExclusiveAccessBubbleViews* GetExclusiveAccessBubble() const = 0;
virtual bool IsTopControlsSlideBehaviorEnabled() const = 0; virtual bool IsTopControlsSlideBehaviorEnabled() const = 0;
virtual float GetTopControlsSlideBehaviorShownRatio() const = 0; virtual float GetTopControlsSlideBehaviorShownRatio() const = 0;
virtual bool SupportsWindowFeature(Browser::WindowFeature feature) const = 0;
virtual gfx::NativeView GetHostView() const = 0;
virtual bool BrowserIsTypeNormal() const = 0;
virtual bool HasFindBarController() const = 0;
virtual void MoveWindowForFindBarIfNecessary() const = 0;
}; };
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_DELEGATE_H_ #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_DELEGATE_H_
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/ui/views/frame/browser_view_layout.h" #include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "base/containers/flat_set.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
...@@ -14,13 +15,13 @@ ...@@ -14,13 +15,13 @@
#include "chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h" #include "chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/tabs/tab_strip_controller.h" #include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/views/chrome_views_test_base.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/controls/separator.h" #include "ui/views/controls/separator.h"
namespace { namespace {
static const int kToolbarHeight = 30 - views::Separator::kThickness; constexpr int kToolbarHeight = 30 - views::Separator::kThickness;
class MockBrowserViewLayoutDelegate : public BrowserViewLayoutDelegate { class MockBrowserViewLayoutDelegate : public BrowserViewLayoutDelegate {
public: public:
...@@ -68,6 +69,22 @@ class MockBrowserViewLayoutDelegate : public BrowserViewLayoutDelegate { ...@@ -68,6 +69,22 @@ class MockBrowserViewLayoutDelegate : public BrowserViewLayoutDelegate {
float GetTopControlsSlideBehaviorShownRatio() const override { float GetTopControlsSlideBehaviorShownRatio() const override {
return top_controls_shown_ratio_; return top_controls_shown_ratio_;
} }
bool SupportsWindowFeature(
const Browser::WindowFeature feature) const override {
static const base::NoDestructor<base::flat_set<Browser::WindowFeature>>
supported_features({
Browser::FEATURE_TABSTRIP,
Browser::FEATURE_TOOLBAR,
Browser::FEATURE_LOCATIONBAR,
Browser::FEATURE_BOOKMARKBAR,
Browser::FEATURE_DOWNLOADSHELF,
});
return base::Contains(*supported_features, feature);
}
gfx::NativeView GetHostView() const override { return nullptr; }
bool BrowserIsTypeNormal() const override { return true; }
bool HasFindBarController() const override { return false; }
void MoveWindowForFindBarIfNecessary() const override {}
private: private:
bool tab_strip_visible_ = true; bool tab_strip_visible_ = true;
...@@ -117,7 +134,7 @@ class MockImmersiveModeController : public ImmersiveModeController { ...@@ -117,7 +134,7 @@ class MockImmersiveModeController : public ImmersiveModeController {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tests of BrowserViewLayout. Runs tests without constructing a BrowserView. // Tests of BrowserViewLayout. Runs tests without constructing a BrowserView.
class BrowserViewLayoutTest : public BrowserWithTestWindowTest { class BrowserViewLayoutTest : public ChromeViewsTestBase {
public: public:
BrowserViewLayoutTest() BrowserViewLayoutTest()
: delegate_(nullptr), : delegate_(nullptr),
...@@ -140,9 +157,8 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest { ...@@ -140,9 +157,8 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest {
InfoBarContainerView* infobar_container() { return infobar_container_; } InfoBarContainerView* infobar_container() { return infobar_container_; }
views::View* contents_container() { return contents_container_; } views::View* contents_container() { return contents_container_; }
// BrowserWithTestWindowTest overrides:
void SetUp() override { void SetUp() override {
BrowserWithTestWindowTest::SetUp(); ChromeViewsTestBase::SetUp();
root_view_.reset(CreateFixedSizeView(gfx::Size(800, 600))); root_view_.reset(CreateFixedSizeView(gfx::Size(800, 600)));
...@@ -158,7 +174,6 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest { ...@@ -158,7 +174,6 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest {
toolbar_ = toolbar_ =
CreateFixedSizeView(gfx::Size(800, 30 - views::Separator::kThickness)); CreateFixedSizeView(gfx::Size(800, 30 - views::Separator::kThickness));
top_container_->AddChildView(toolbar_); top_container_->AddChildView(toolbar_);
top_container_->AddChildView(toolbar_);
separator_ = separator_ =
top_container_->AddChildView(std::make_unique<views::Separator>()); top_container_->AddChildView(std::make_unique<views::Separator>());
root_view_->AddChildView(top_container_); root_view_->AddChildView(top_container_);
...@@ -182,7 +197,8 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest { ...@@ -182,7 +197,8 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest {
// TODO(jamescook): Attach |layout_| to |root_view_|? // TODO(jamescook): Attach |layout_| to |root_view_|?
delegate_ = new MockBrowserViewLayoutDelegate(); delegate_ = new MockBrowserViewLayoutDelegate();
layout_ = std::make_unique<BrowserViewLayout>( layout_ = std::make_unique<BrowserViewLayout>(
std::unique_ptr<BrowserViewLayoutDelegate>(delegate_), browser(), std::unique_ptr<BrowserViewLayoutDelegate>(delegate_),
nullptr, // NativeView.
nullptr, // BrowserView. nullptr, // BrowserView.
top_container_, tab_strip_region_view, tab_strip_, nullptr, toolbar_, top_container_, tab_strip_region_view, tab_strip_, nullptr, toolbar_,
infobar_container_, contents_container_, infobar_container_, contents_container_,
...@@ -211,7 +227,6 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest { ...@@ -211,7 +227,6 @@ class BrowserViewLayoutTest : public BrowserWithTestWindowTest {
// Test basic construction and initialization. // Test basic construction and initialization.
TEST_F(BrowserViewLayoutTest, BrowserViewLayout) { TEST_F(BrowserViewLayoutTest, BrowserViewLayout) {
EXPECT_TRUE(layout()->browser());
EXPECT_TRUE(layout()->GetWebContentsModalDialogHost()); EXPECT_TRUE(layout()->GetWebContentsModalDialogHost());
EXPECT_FALSE(layout()->IsInfobarVisible()); EXPECT_FALSE(layout()->IsInfobarVisible());
} }
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
namespace views { namespace views {
// static
const int Separator::kThickness = 1;
Separator::Separator() = default; Separator::Separator() = default;
Separator::~Separator() = default; Separator::~Separator() = default;
......
...@@ -20,7 +20,7 @@ class VIEWS_EXPORT Separator : public View { ...@@ -20,7 +20,7 @@ class VIEWS_EXPORT Separator : public View {
METADATA_HEADER(Separator); METADATA_HEADER(Separator);
// The separator's thickness in dip. // The separator's thickness in dip.
static const int kThickness; static constexpr int kThickness = 1;
Separator(); Separator();
~Separator() override; ~Separator() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment