Commit 78276705 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Clean up SharingDialogView and avoid needing friend decls for testing.

Some of this cleanup will facilitate replacing ButtonListener with
callbacks in a future CL.

Bug: none
Change-Id: Ieefc3be0238bdaa95fc171b7ee7c55e4f8e41a90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2472899
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818987}
parent f36eb8bd
......@@ -146,7 +146,7 @@ void ClickToCallContextMenuObserver::SendClickToCallMessage(
if (size_t{chosen_device_index} >= devices_.size())
return;
LogSharingSelectedDeviceIndex(controller_->GetFeatureMetricsPrefix(),
LogSharingSelectedIndex(controller_->GetFeatureMetricsPrefix(),
kSharingUiContextMenu, chosen_device_index);
controller_->OnDeviceSelected(phone_number_, *devices_[chosen_device_index],
......
......@@ -141,7 +141,7 @@ void SharedClipboardContextMenuObserver::SendSharedClipboardMessage(
int chosen_device_index) {
if (size_t{chosen_device_index} >= devices_.size())
return;
LogSharingSelectedDeviceIndex(controller_->GetFeatureMetricsPrefix(),
LogSharingSelectedIndex(controller_->GetFeatureMetricsPrefix(),
nullptr /* No suffix */, chosen_device_index);
controller_->OnDeviceSelected(text_, *devices_[chosen_device_index]);
......
......@@ -211,38 +211,20 @@ void LogSharingAppsToShow(SharingFeatureName feature,
/*value_max=*/20);
}
void LogSharingSelectedDeviceIndex(SharingFeatureName feature,
void LogSharingSelectedIndex(SharingFeatureName feature,
const char* histogram_suffix,
int index) {
int index,
SharingIndexType index_type) {
auto* feature_str = GetEnumStringValue(feature);
// Explicitly log both the base and the suffixed histogram because the base
// aggregation is not automatically generated.
base::UmaHistogramExactLinear(
base::StrCat({"Sharing.", feature_str, "SelectedDeviceIndex"}), index,
/*value_max=*/20);
if (!histogram_suffix)
return;
base::UmaHistogramExactLinear(
base::StrCat(
{"Sharing.", feature_str, "SelectedDeviceIndex.", histogram_suffix}),
index,
/*value_max=*/20);
}
void LogSharingSelectedAppIndex(SharingFeatureName feature,
const char* histogram_suffix,
int index) {
auto* feature_str = GetEnumStringValue(feature);
// Explicitly log both the base and the suffixed histogram because the base
// aggregation is not automatically generated.
base::UmaHistogramExactLinear(
base::StrCat({"Sharing.", feature_str, "SelectedAppIndex"}), index,
/*value_max=*/20);
std::string name = base::StrCat(
{"Sharing.", feature_str, "Selected",
(index_type == SharingIndexType::kDevice) ? "Device" : "App", "Index"});
base::UmaHistogramExactLinear(name, index, /*value_max=*/20);
if (!histogram_suffix)
return;
base::UmaHistogramExactLinear(
base::StrCat(
{"Sharing.", feature_str, "SelectedAppIndex.", histogram_suffix}),
base::UmaHistogramExactLinear(base::StrCat({name, ".", histogram_suffix}),
index,
/*value_max=*/20);
}
......
......@@ -79,21 +79,20 @@ void LogSharingAppsToShow(SharingFeatureName feature,
const char* histogram_suffix,
int count);
// Logs the |index| of the device selected by the user for sharing feature. The
// |histogram_suffix| indicates in which UI this event happened and must match
// one from Sharing{feature}Ui defined in histograms.xml - use the
// constants defined in this file for that.
void LogSharingSelectedDeviceIndex(SharingFeatureName feature,
const char* histogram_suffix,
int index);
// Logs the |index| of the app selected by the user for sharing feature. The
// |histogram_suffix| indicates in which UI this event happened and must match
// one from Sharing{feature}Ui defined in histograms.xml - use the
// constants defined in this file for that.
void LogSharingSelectedAppIndex(SharingFeatureName feature,
// Logs the |index| of the user selection for sharing feature. |index_type| is
// the type of selection made, either "Device" or "App". The |histogram_suffix|
// indicates in which UI this event happened and must match one from
// Sharing{feature}Ui defined in histograms.xml - use the constants defined in
// this file for that.
enum class SharingIndexType {
kDevice,
kApp,
};
void LogSharingSelectedIndex(
SharingFeatureName feature,
const char* histogram_suffix,
int index);
int index,
SharingIndexType index_type = SharingIndexType::kDevice);
// Logs to UMA the time from sending a FCM message from the Sharing service
// until an ack message is received for it.
......
......@@ -40,6 +40,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/test/button_test_api.h"
#include "url/gurl.h"
namespace {
......@@ -402,15 +403,13 @@ IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest, LeftClick_ChooseDevice) {
static_cast<SharingDialogView*>(controller->dialog());
EXPECT_EQ(SharingDialogType::kDialogWithDevicesMaybeApps,
dialog->GetDialogType());
EXPECT_EQ(1u, dialog->data_.devices.size());
EXPECT_EQ(dialog->data_.devices.size() + dialog->data_.apps.size(),
dialog->dialog_buttons_.size());
const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), 0, 0);
// Choose first device.
dialog->ButtonPressed(dialog->dialog_buttons_[0], event);
const auto& buttons = dialog->button_list_for_testing()->children();
ASSERT_GT(buttons.size(), 0u);
views::test::ButtonTestApi(static_cast<views::Button*>(buttons[0]))
.NotifyClick(ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(),
gfx::Point(), ui::EventTimeForNow(), 0, 0));
CheckLastReceiver(*devices[0]);
// Defined in tel.html
......
......@@ -175,26 +175,21 @@ SharingDialogType SharingDialogView::GetDialogType() const {
void SharingDialogView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK(data_.device_callback);
DCHECK(data_.app_callback);
if (!sender || sender->tag() < 0)
return;
size_t index{sender->tag()};
if (index < data_.devices.size()) {
LogSharingSelectedDeviceIndex(data_.prefix, kSharingUiDialog, index);
std::move(data_.device_callback).Run(*data_.devices[index]);
CloseBubble();
return;
}
DCHECK(sender);
size_t index = sender->tag();
DCHECK_LT(index, data_.devices.size() + data_.apps.size());
const bool is_device = index < data_.devices.size();
if (!is_device)
index -= data_.devices.size();
if (index < data_.apps.size()) {
LogSharingSelectedAppIndex(data_.prefix, kSharingUiDialog, index);
LogSharingSelectedIndex(
data_.prefix, kSharingUiDialog, index,
is_device ? SharingIndexType::kDevice : SharingIndexType::kApp);
if (is_device)
std::move(data_.device_callback).Run(*data_.devices[index]);
else
std::move(data_.app_callback).Run(data_.apps[index]);
CloseBubble();
}
}
// static
......@@ -271,14 +266,13 @@ void SharingDialogView::InitListView() {
: kHardwareSmartphoneIcon,
kPrimaryIconSize);
auto dialog_button = std::make_unique<HoverButton>(
auto* dialog_button =
button_list->AddChildView(std::make_unique<HoverButton>(
this, std::move(icon), base::UTF8ToUTF16(device->client_name()),
GetLastUpdatedTimeInDays(device->last_updated_timestamp()));
GetLastUpdatedTimeInDays(device->last_updated_timestamp())));
dialog_button->SetEnabled(true);
dialog_button->set_tag(tag++);
dialog_button->SetBorder(views::CreateEmptyBorder(device_border));
dialog_buttons_.push_back(
button_list->AddChildView(std::move(dialog_button)));
}
// Apps:
......@@ -293,32 +287,32 @@ void SharingDialogView::InitListView() {
icon->SetImage(app.image.AsImageSkia());
}
auto dialog_button =
auto* dialog_button = button_list->AddChildView(
std::make_unique<HoverButton>(this, std::move(icon), app.name,
/* subtitle= */ base::string16());
/* subtitle= */ base::string16()));
dialog_button->SetEnabled(true);
dialog_button->set_tag(tag++);
dialog_button->SetBorder(views::CreateEmptyBorder(app_border));
dialog_buttons_.push_back(
button_list->AddChildView(std::move(dialog_button)));
}
// Allow up to 5 buttons in the list and let the rest scroll.
constexpr size_t kMaxDialogButtons = 5;
if (dialog_buttons_.size() > kMaxDialogButtons) {
if (button_list->children().size() > kMaxDialogButtons) {
const int bubble_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH);
int max_list_height = 0;
for (size_t i = 0; i < kMaxDialogButtons; ++i)
max_list_height += dialog_buttons_[i]->GetHeightForWidth(bubble_width);
for (size_t i = 0; i < kMaxDialogButtons; ++i) {
max_list_height +=
button_list->children()[i]->GetHeightForWidth(bubble_width);
}
DCHECK_GT(max_list_height, 0);
auto* scroll_view = AddChildView(std::make_unique<views::ScrollView>());
scroll_view->ClipHeightTo(0, max_list_height);
scroll_view->SetContents(std::move(button_list));
button_list_ = scroll_view->SetContents(std::move(button_list));
} else {
AddChildView(std::move(button_list));
button_list_ = AddChildView(std::move(button_list));
}
}
......
......@@ -18,7 +18,6 @@ class StyledLabel;
class View;
} // namespace views
class HoverButton;
enum class SharingDialogType;
class SharingDialogView : public SharingDialog,
......@@ -46,22 +45,15 @@ class SharingDialogView : public SharingDialog,
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
static views::BubbleDialogDelegateView* GetAsBubble(SharingDialog* dialog);
static views::BubbleDialogDelegateView* GetAsBubbleForClickToCall(
SharingDialog* dialog);
private:
friend class SharingDialogViewTest;
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, PopulateDialogView);
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, DevicePressed);
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, AppPressed);
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, HelpTextClickedEmpty);
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, HelpTextClickedOnlyApps);
FRIEND_TEST_ALL_PREFIXES(SharingDialogViewTest, ThemeChangedEmptyList);
SharingDialogType GetDialogType() const;
FRIEND_TEST_ALL_PREFIXES(ClickToCallBrowserTest, LeftClick_ChooseDevice);
const View* button_list_for_testing() const { return button_list_; }
SharingDialogType GetDialogType() const;
private:
friend class SharingDialogViewTest;
// LocationBarBubbleDelegateView:
void Init() override;
......@@ -76,7 +68,7 @@ class SharingDialogView : public SharingDialog,
SharingDialogData data_;
// References to device and app buttons views.
std::vector<HoverButton*> dialog_buttons_;
View* button_list_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(SharingDialogView);
};
......
......@@ -7,12 +7,13 @@
#include <memory>
#include <string>
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h"
#include "chrome/browser/sharing/fake_device_info.h"
#include "chrome/browser/sharing/sharing_app.h"
#include "chrome/browser/sharing/sharing_metrics.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/ui/views/hover_button.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/test/base/browser_with_test_window_test.h"
......@@ -28,74 +29,59 @@
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/test/button_test_api.h"
#include "url/gurl.h"
#include "url/origin.h"
using ::testing::Property;
namespace {
class SharingDialogViewFake : public SharingDialogView {
public:
SharingDialogViewFake(views::View* anchor_view,
content::WebContents* web_contents,
SharingDialogData data)
: SharingDialogView(anchor_view, web_contents, std::move(data)) {}
~SharingDialogViewFake() override = default;
// The delegate cannot find widget since it is created from a null profile.
// This method will be called inside ButtonPressed(). Unit tests will
// crash without mocking.
void CloseBubble() override {}
};
} // namespace
MATCHER_P(AppEquals, app, "") {
return app->name == arg.name;
}
class SharingDialogViewTest : public BrowserWithTestWindowTest {
class SharingDialogViewTest : public TestWithBrowserView {
protected:
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
TestWithBrowserView::SetUp();
// We create |web_contents| to have a valid commited page origin to check
// We create |web_contents_| to have a valid committed page origin to check
// against when showing the origin view.
GURL url("https://google.com");
web_contents_ = browser()->OpenURL(content::OpenURLParams(
url, content::Referrer(), WindowOpenDisposition::CURRENT_TAB,
ui::PAGE_TRANSITION_TYPED, false));
GURL("https://google.com"), content::Referrer(),
WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false));
CommitPendingLoad(&web_contents_->GetController());
}
void TearDown() override {
if (dialog_)
dialog_->GetWidget()->CloseNow();
TestWithBrowserView::TearDown();
}
std::vector<std::unique_ptr<syncer::DeviceInfo>> CreateDevices(int count) {
std::vector<std::unique_ptr<syncer::DeviceInfo>> devices;
for (int i = 0; i < count; i++) {
devices.emplace_back(CreateFakeDeviceInfo(
base::StrCat({"guid_", base::NumberToString(i)}),
base::StrCat({"name_", base::NumberToString(i)})));
for (int i = 0; i < count; ++i) {
devices.push_back(
CreateFakeDeviceInfo("guid_" + base::NumberToString(i),
"name_" + base::NumberToString(i)));
}
return devices;
}
std::vector<SharingApp> CreateApps(int count) {
std::vector<SharingApp> apps;
for (int i = 0; i < count; i++) {
apps.emplace_back(
&vector_icons::kOpenInNewIcon, gfx::Image(),
base::UTF8ToUTF16(base::StrCat({"app", base::NumberToString(i)})),
base::StrCat({"app_id_", base::NumberToString(i)}));
for (int i = 0; i < count; ++i) {
apps.emplace_back(&vector_icons::kOpenInNewIcon, gfx::Image(),
base::UTF8ToUTF16("app" + base::NumberToString(i)),
"app_id_" + base::NumberToString(i));
}
return apps;
}
std::unique_ptr<SharingDialogView> CreateDialogView(
SharingDialogData dialog_data) {
auto dialog = std::make_unique<SharingDialogViewFake>(
/*anchor_view=*/nullptr, web_contents_, std::move(dialog_data));
dialog->Init();
return dialog;
void CreateDialogView(SharingDialogData dialog_data) {
dialog_ = new SharingDialogView(browser_view(), web_contents_,
std::move(dialog_data));
views::BubbleDialogDelegateView::CreateBubble(dialog_);
}
SharingDialogData CreateDialogData(int devices, int apps) {
......@@ -129,16 +115,21 @@ class SharingDialogViewTest : public BrowserWithTestWindowTest {
return data;
}
SharingDialogView* dialog() { return dialog_; }
testing::MockFunction<void(const syncer::DeviceInfo&)> device_callback_;
testing::MockFunction<void(const SharingApp&)> app_callback_;
private:
content::WebContents* web_contents_ = nullptr;
SharingDialogView* dialog_ = nullptr;
};
TEST_F(SharingDialogViewTest, PopulateDialogView) {
auto dialog_data = CreateDialogData(/*devices=*/3, /*apps=*/2);
auto dialog = CreateDialogView(std::move(dialog_data));
CreateDialogView(std::move(dialog_data));
EXPECT_EQ(5UL, dialog->dialog_buttons_.size());
EXPECT_EQ(5U, dialog()->button_list_for_testing()->children().size());
}
TEST_F(SharingDialogViewTest, DevicePressed) {
......@@ -146,13 +137,14 @@ TEST_F(SharingDialogViewTest, DevicePressed) {
Call(Property(&syncer::DeviceInfo::guid, "guid_1")));
auto dialog_data = CreateDialogData(/*devices=*/3, /*apps=*/2);
auto dialog = CreateDialogView(std::move(dialog_data));
const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), 0, 0);
CreateDialogView(std::move(dialog_data));
// Choose second device: device0(tag=0), device1(tag=1)
dialog->ButtonPressed(dialog->dialog_buttons_[1], event);
const auto& buttons = dialog()->button_list_for_testing()->children();
ASSERT_EQ(5U, buttons.size());
views::test::ButtonTestApi(static_cast<views::Button*>(buttons[1]))
.NotifyClick(ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(),
gfx::Point(), ui::EventTimeForNow(), 0, 0));
}
TEST_F(SharingDialogViewTest, AppPressed) {
......@@ -161,83 +153,95 @@ TEST_F(SharingDialogViewTest, AppPressed) {
EXPECT_CALL(app_callback_, Call(AppEquals(&app)));
auto dialog_data = CreateDialogData(/*devices=*/3, /*apps=*/2);
auto dialog = CreateDialogView(std::move(dialog_data));
const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), 0, 0);
CreateDialogView(std::move(dialog_data));
// Choose first app: device0(tag=0), device1(tag=1), device2(tag=2),
// app0(tag=3)
dialog->ButtonPressed(dialog->dialog_buttons_[3], event);
const auto& buttons = dialog()->button_list_for_testing()->children();
ASSERT_EQ(5U, buttons.size());
views::test::ButtonTestApi(static_cast<views::Button*>(buttons[3]))
.NotifyClick(ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(),
gfx::Point(), ui::EventTimeForNow(), 0, 0));
}
TEST_F(SharingDialogViewTest, ThemeChangedEmptyList) {
auto dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
dialog_data.type = SharingDialogType::kErrorDialog;
auto dialog = CreateDialogView(std::move(dialog_data));
CreateDialogView(std::move(dialog_data));
EXPECT_EQ(SharingDialogType::kErrorDialog, dialog->GetDialogType());
EXPECT_EQ(SharingDialogType::kErrorDialog, dialog()->GetDialogType());
// Regression test for crbug.com/1001112
dialog->OnThemeChanged();
dialog()->GetWidget()->ThemeChanged();
}
TEST_F(SharingDialogViewTest, OriginView) {
TEST_F(SharingDialogViewTest, FootnoteNoOrigin) {
auto dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
auto dialog = CreateDialogView(std::move(dialog_data));
CreateDialogView(std::move(dialog_data));
// No footnote by default if there is no initiating origin set.
EXPECT_EQ(nullptr, dialog->GetFootnoteViewForTesting());
EXPECT_EQ(nullptr, dialog()->GetFootnoteViewForTesting());
}
TEST_F(SharingDialogViewTest, FootnoteCurrentOrigin) {
auto dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
dialog_data.initiating_origin =
url::Origin::Create(GURL("https://google.com"));
CreateDialogView(std::move(dialog_data));
// No footnote if the initiating origin matches the main frame origin.
EXPECT_EQ(nullptr, dialog()->GetFootnoteViewForTesting());
}
dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
TEST_F(SharingDialogViewTest, FootnoteOtherOrigin) {
auto dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
dialog_data.initiating_origin =
url::Origin::Create(GURL("https://example.com"));
dialog = CreateDialogView(std::move(dialog_data));
CreateDialogView(std::move(dialog_data));
// Origin should be shown in the footnote if the initiating origin does not
// match the main frame origin.
EXPECT_NE(nullptr, dialog->GetFootnoteViewForTesting());
EXPECT_NE(nullptr, dialog()->GetFootnoteViewForTesting());
}
dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
TEST_F(SharingDialogViewTest, HelpTextNoOrigin) {
base::string16 expected_default = l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES);
// Expect default help text if no initiating origin is set.
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
CreateDialogView(std::move(dialog_data));
EXPECT_EQ(expected_default, static_cast<views::StyledLabel*>(
dialog()->GetFootnoteViewForTesting())
->GetText());
}
TEST_F(SharingDialogViewTest, HelpTextCurrentOrigin) {
base::string16 expected_default = l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES);
// Expect default help text if the initiating origin matches the main frame
// origin.
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
dialog_data.initiating_origin =
url::Origin::Create(GURL("https://google.com"));
dialog = CreateDialogView(std::move(dialog_data));
// Origin should not be shown in the footnote if the initiating origin does
// match the main frame origin.
EXPECT_EQ(nullptr, dialog->GetFootnoteViewForTesting());
CreateDialogView(std::move(dialog_data));
EXPECT_EQ(expected_default, static_cast<views::StyledLabel*>(
dialog()->GetFootnoteViewForTesting())
->GetText());
}
TEST_F(SharingDialogViewTest, HelpTextContent) {
url::Origin current_origin = url::Origin::Create(GURL("https://google.com"));
TEST_F(SharingDialogViewTest, HelpTextOtherOrigin) {
url::Origin other_origin = url::Origin::Create(GURL("https://example.com"));
base::string16 origin_text = url_formatter::FormatOriginForSecurityDisplay(
other_origin, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
base::string16 expected_default = l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES);
base::string16 expected_origin = l10n_util::GetStringFUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES_ORIGIN,
origin_text);
// Expect default help text if no initiating origin is set.
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
auto dialog = CreateDialogView(std::move(dialog_data));
views::View* footnote_view = dialog->GetFootnoteViewForTesting();
EXPECT_EQ(expected_default,
static_cast<views::StyledLabel*>(footnote_view)->GetText());
// Still expect the default help text if the initiating origin matches the
// main frame origin.
dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
dialog_data.initiating_origin = current_origin;
dialog = CreateDialogView(std::move(dialog_data));
footnote_view = dialog->GetFootnoteViewForTesting();
EXPECT_EQ(expected_default,
static_cast<views::StyledLabel*>(footnote_view)->GetText());
// Expect the origin to be included in the help text if it does not match the
// main frame origin.
dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
auto dialog_data = CreateDialogData(/*devices=*/0, /*apps=*/1);
dialog_data.initiating_origin = other_origin;
dialog = CreateDialogView(std::move(dialog_data));
footnote_view = dialog->GetFootnoteViewForTesting();
EXPECT_EQ(expected_origin,
static_cast<views::StyledLabel*>(footnote_view)->GetText());
CreateDialogView(std::move(dialog_data));
EXPECT_EQ(expected_origin, static_cast<views::StyledLabel*>(
dialog()->GetFootnoteViewForTesting())
->GetText());
}
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