Skip to content

Commit

Permalink
Fix browser test for new icon and clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Oct 14, 2020
1 parent f097016 commit 008196f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
8 changes: 4 additions & 4 deletions browser/tor/onion_location_navigation_throttle_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class OnionLocationNavigationThrottleBrowserTest : public InProcessBrowserTest {
BraveLocationBarView* brave_location_bar_view =
static_cast<BraveLocationBarView*>(browser_view->GetLocationBarView());
ASSERT_NE(brave_location_bar_view, nullptr);
OnionLocationView* onion_label =
brave_location_bar_view->GetOnionLocationView();
EXPECT_TRUE(onion_label->GetVisible());
EXPECT_EQ(onion_label->GetText(),
views::LabelButton* onion_button =
brave_location_bar_view->GetOnionLocationView()->GetButton();
EXPECT_TRUE(onion_button->GetVisible());
EXPECT_EQ(onion_button->GetText(),
l10n_util::GetStringUTF16((IDS_LOCATION_BAR_OPEN_IN_TOR)));
}

Expand Down
24 changes: 10 additions & 14 deletions browser/ui/views/location_bar/onion_location_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h"
#include "components/grit/brave_components_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/models/image_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
Expand Down Expand Up @@ -59,8 +59,7 @@ void OnTorProfileCreated(GURL onion_location,

// Sets the focus and ink drop highlight path to match the background
// along with it's corner radius.
class HighlightPathGenerator
: public views::HighlightPathGenerator {
class HighlightPathGenerator : public views::HighlightPathGenerator {
public:
HighlightPathGenerator() = default;

Expand All @@ -77,18 +76,18 @@ class HighlightPathGenerator
};

class OnionLocationButtonView : public views::LabelButton,
public views::ButtonListener {
public views::ButtonListener {
public:
explicit OnionLocationButtonView(Profile* profile)
: LabelButton(this,
l10n_util::GetStringUTF16(IDS_LOCATION_BAR_OPEN_IN_TOR)) {
l10n_util::GetStringUTF16(IDS_LOCATION_BAR_OPEN_IN_TOR)) {
if (brave::IsTorProfile(profile))
SetText(l10n_util::GetStringUTF16(IDS_LOCATION_BAR_ONION_AVAILABLE));
// Render vector icon
const gfx::ImageSkia image = gfx::CreateVectorIcon(
kOpenInTorIcon, kIconSize, kIconColor);
const gfx::ImageSkia image =
gfx::CreateVectorIcon(kOpenInTorIcon, kIconSize, kIconColor);
SetImageModel(views::Button::STATE_NORMAL,
ui::ImageModel::FromImageSkia(image));
ui::ImageModel::FromImageSkia(image));
// Set style specifics
SetEnabledTextColors(kTextColor);
SetHorizontalAlignment(gfx::ALIGN_RIGHT);
Expand All @@ -104,17 +103,15 @@ class OnionLocationButtonView : public views::LabelButton,
this, std::make_unique<HighlightPathGenerator>());
}

~OnionLocationButtonView() override { }
~OnionLocationButtonView() override {}

// views::ButtonListener
void ButtonPressed(Button* sender, const ui::Event& event) override {
profiles::SwitchToTorProfile(
base::BindRepeating(&OnTorProfileCreated, GURL(onion_location_)));
}

void SetOnionLocation(GURL location) {
onion_location_ = location;
}
void SetOnionLocation(GURL location) { onion_location_ = location; }

private:
// views::View
Expand All @@ -125,7 +122,7 @@ class OnionLocationButtonView : public views::LabelButton,

void UpdateBorder() {
SetBackground(
views::CreateRoundedRectBackground(kOpenInTorBg, height() / 2));
views::CreateRoundedRectBackground(kOpenInTorBg, height() / 2));
}

GURL onion_location_;
Expand All @@ -138,7 +135,6 @@ class OnionLocationButtonView : public views::LabelButton,

OnionLocationView::OnionLocationView(Profile* profile) {
SetBorder(views::CreateEmptyBorder(gfx::Insets(3, 3)));
// GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING)));
SetVisible(false);
// automatic layout
auto vertical_container_layout = std::make_unique<views::BoxLayout>(
Expand Down
6 changes: 4 additions & 2 deletions browser/ui/views/location_bar/onion_location_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#ifndef BRAVE_BROWSER_UI_VIEWS_LOCATION_BAR_ONION_LOCATION_VIEW_H_
#define BRAVE_BROWSER_UI_VIEWS_LOCATION_BAR_ONION_LOCATION_VIEW_H_

#include "ui/gfx/geometry/size.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/gfx/geometry/size.h"

class Profile;

Expand All @@ -23,8 +23,10 @@ class OnionLocationView : public views::View {

void Update(content::WebContents* web_contents);

views::LabelButton* GetButton() { return button_; }

private:
View* button_ = nullptr;
views::LabelButton* button_ = nullptr;

OnionLocationView(const OnionLocationView&) = delete;
OnionLocationView& operator=(const OnionLocationView&) = delete;
Expand Down

0 comments on commit 008196f

Please sign in to comment.