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

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc

Issue 2206693002: Improve settings override bubble to indicate policy installed extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc
diff --git a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc
index d5d1f6cbcb1c9d8f41441d5ba5764e3c12df8406..643780652ec9b3899ba674dc876c48e7e6f39e4b 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc
@@ -9,8 +9,18 @@
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_bubble_delegate.h"
+#include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/grit/components_scaled_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
+#include "ui/gfx/color_palette.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_unittest_util.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icons_public.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/link.h"
#include "ui/views/test/test_widget_observer.h"
@@ -18,7 +28,17 @@
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_client_view.h"
+namespace {
+const int kIconSize = 16;
+}
+
class ToolbarActionsBarBubbleViewsTest : public views::ViewsTestBase {
+ public:
+ views::View* TestCreateExtraView() {
+ DCHECK(bubble_);
+ return bubble_->CreateExtraView();
+ }
+
protected:
ToolbarActionsBarBubbleViewsTest() {}
~ToolbarActionsBarBubbleViewsTest() override {}
@@ -99,12 +119,28 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestBubbleLayoutActionButton) {
CloseBubble();
}
+TEST_F(ToolbarActionsBarBubbleViewsTest, TestBubbleLayoutNoButtons) {
+ TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
+ ActionString());
+ ToolbarActionsBarBubbleDelegate::ExtraViewInfo extra_view_info;
+ delegate.set_extra_view_info(extra_view_info);
+ delegate.set_dismiss_button_text(base::string16());
+ delegate.set_action_button_text(base::string16());
+ ShowBubble(&delegate);
+
+ std::unique_ptr<views::View> extra_view(TestCreateExtraView());
+ EXPECT_FALSE(bubble()->GetDialogClientView()->ok_button());
+ EXPECT_FALSE(bubble()->GetDialogClientView()->cancel_button());
+ EXPECT_FALSE(bubble()->learn_more_button());
+
+ CloseBubble();
+}
+
TEST_F(ToolbarActionsBarBubbleViewsTest,
TestBubbleLayoutActionAndDismissButton) {
TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
ActionString());
delegate.set_dismiss_button_text(DismissString());
-
ShowBubble(&delegate);
EXPECT_TRUE(bubble()->GetDialogClientView()->ok_button());
@@ -125,7 +161,13 @@ TEST_F(ToolbarActionsBarBubbleViewsTest,
TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
ActionString());
delegate.set_dismiss_button_text(DismissString());
- delegate.set_learn_more_button_text(LearnMoreString());
+
+ ToolbarActionsBarBubbleDelegate::ExtraViewInfo extra_view_info_linked_text;
+
+ extra_view_info_linked_text.text = LearnMoreString();
+ extra_view_info_linked_text.is_text_linked = true;
+ delegate.set_extra_view_info(extra_view_info_linked_text);
+
ShowBubble(&delegate);
EXPECT_TRUE(bubble()->GetDialogClientView()->ok_button());
@@ -260,3 +302,96 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestDontCloseOnDeactivation) {
EXPECT_FALSE(delegate.close_action());
CloseBubble();
}
+
+TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewIconOnly) {
+ TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
+ ActionString());
+ ToolbarActionsBarBubbleDelegate::ExtraViewInfo extra_view_info;
+
+ extra_view_info.resource_id = gfx::VectorIconId::BUSINESS;
+ delegate.set_extra_view_info(extra_view_info);
+ ShowBubble(&delegate);
+ std::unique_ptr<views::View> extra_view(TestCreateExtraView());
+ ASSERT_TRUE(extra_view);
+ ASSERT_EQ("ImageView", std::string(extra_view->GetClassName()));
+ EXPECT_TRUE(gfx::test::AreImagesEqual(
+ gfx::Image(static_cast<views::ImageView*>(extra_view.get())->GetImage()),
+ gfx::Image(gfx::CreateVectorIcon(gfx::VectorIconId::BUSINESS, kIconSize,
+ gfx::kChromeIconGrey))));
+ CloseBubble();
+}
+
+TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewLinkedTextOnly) {
+ TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
+ ActionString());
+ ToolbarActionsBarBubbleDelegate::ExtraViewInfo extra_view_info_linked_text;
+
+ extra_view_info_linked_text.text =
+ l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN);
+ extra_view_info_linked_text.is_text_linked = true;
+ delegate.set_extra_view_info(extra_view_info_linked_text);
+
+ ShowBubble(&delegate);
+
+ std::unique_ptr<views::View> extra_view(TestCreateExtraView());
+ ASSERT_TRUE(extra_view);
+ ASSERT_EQ("Link", std::string(extra_view->GetClassName()));
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN),
+ static_cast<views::Label*>(extra_view.get())->text());
+ CloseBubble();
+}
+
+TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewLabelTextOnly) {
+ TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
+ ActionString());
+ ToolbarActionsBarBubbleDelegate::ExtraViewInfo extra_view_info;
+
+ extra_view_info.text =
+ l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN);
+ extra_view_info.is_text_linked = false;
+ delegate.set_extra_view_info(extra_view_info);
+
+ ShowBubble(&delegate);
+
+ std::unique_ptr<views::View> extra_view(TestCreateExtraView());
+ ASSERT_TRUE(extra_view);
+ EXPECT_EQ("Label", std::string(extra_view->GetClassName()));
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN),
+ static_cast<views::Label*>(extra_view.get())->text());
+ CloseBubble();
+}
+
+TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewImageAndText) {
+ TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
+ ActionString());
+ ToolbarActionsBarBubbleDelegate::ExtraViewInfo extra_view_info;
+ extra_view_info.resource_id = gfx::VectorIconId::BUSINESS;
+ extra_view_info.text =
+ l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN);
+ extra_view_info.is_text_linked = false;
+ delegate.set_extra_view_info(extra_view_info);
+
+ ShowBubble(&delegate);
+
+ std::unique_ptr<views::View> extra_view(TestCreateExtraView());
+ ASSERT_TRUE(extra_view);
+ EXPECT_EQ("View", std::string(extra_view->GetClassName()));
+ EXPECT_EQ(2, extra_view->child_count());
+
+ for (int i = 0; i < 2; i++) {
+ const views::View* v = extra_view->child_at(i);
+ std::string class_name = v->GetClassName();
+ ASSERT_TRUE(class_name == "Label" || class_name == "ImageView");
+ if (class_name == "Label") {
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN),
+ static_cast<const views::Label*>(v)->text());
+ } else {
+ EXPECT_TRUE(gfx::test::AreImagesEqual(
+ gfx::Image(static_cast<const views::ImageView*>(v)->GetImage()),
+ gfx::Image(gfx::CreateVectorIcon(gfx::VectorIconId::BUSINESS,
+ kIconSize, gfx::kChromeIconGrey))));
+ }
+ }
+
+ CloseBubble();
+}
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698