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

Unified Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view_unittest.cc

Issue 2725783004: views: align columns in site settings dialog (Closed)
Patch Set: fixes Created 3 years, 9 months 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/website_settings/website_settings_popup_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/website_settings/website_settings_popup_view_unittest.cc
diff --git a/chrome/browser/ui/views/website_settings/website_settings_popup_view_unittest.cc b/chrome/browser/ui/views/website_settings/website_settings_popup_view_unittest.cc
index 6b6db780ed0ba1f45424f1244560baabdb29c057..5e9255dc9fee5d246f4eac8b669386988d37385e 100644
--- a/chrome/browser/ui/views/website_settings/website_settings_popup_view_unittest.cc
+++ b/chrome/browser/ui/views/website_settings/website_settings_popup_view_unittest.cc
@@ -56,13 +56,21 @@ class WebsiteSettingsPopupViewTestApi {
views::View* permissions_view() { return view_->permissions_view_; }
PermissionSelectorRow* GetPermissionSelectorAt(int index) {
- return static_cast<PermissionSelectorRow*>(
- permissions_view()->child_at(index));
+ return view_->selector_rows_[index].get();
+ }
+
+ // Returns the permission label text of the |index|th permission selector row.
+ // This function returns an empty string if the permission selector row's
+ // |label_| element isn't actually a |views::Label|.
+ base::string16 GetPermissionLabelTextAt(int index) {
+ views::View* view = GetPermissionSelectorAt(index)->label_;
+ if (view->GetClassName() == views::Label::kViewClassName)
+ return static_cast<views::Label*>(view)->text();
+ return base::string16();
}
base::string16 GetPermissionButtonTextAt(int index) {
- const int kButtonIndex = 2; // Button should be the third child.
- views::View* view = GetPermissionSelectorAt(index)->child_at(kButtonIndex);
+ views::View* view = GetPermissionSelectorAt(index)->button();
if (view->GetClassName() == views::MenuButton::kViewClassName) {
return static_cast<views::MenuButton*>(view)->GetText();
} else if (view->GetClassName() == views::Combobox::kViewClassName) {
@@ -165,6 +173,9 @@ class WebsiteSettingsPopupViewTest : public testing::Test {
#define MAYBE_SetPermissionInfo SetPermissionInfo
#endif
+// Each permission selector row is like this: [icon] [label] [selector]
+constexpr int kViewsPerPermissionRow = 3;
+
// Test UI construction and reconstruction via
// WebsiteSettingsPopupView::SetPermissionInfo().
TEST_F(WebsiteSettingsPopupViewTest, MAYBE_SetPermissionInfo) {
@@ -175,7 +186,8 @@ TEST_F(WebsiteSettingsPopupViewTest, MAYBE_SetPermissionInfo) {
list.back().setting = CONTENT_SETTING_DEFAULT;
const int kExpectedChildren =
- ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 11 : 13;
+ kViewsPerPermissionRow *
+ (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 11 : 13);
EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count());
list.back().setting = CONTENT_SETTING_ALLOW;
@@ -183,15 +195,10 @@ TEST_F(WebsiteSettingsPopupViewTest, MAYBE_SetPermissionInfo) {
EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count());
PermissionSelectorRow* selector = api_->GetPermissionSelectorAt(0);
- EXPECT_EQ(3, selector->child_count());
+ EXPECT_TRUE(selector);
// Verify labels match the settings on the PermissionInfoList.
- const int kLabelIndex = 1;
- EXPECT_EQ(views::Label::kViewClassName,
- selector->child_at(kLabelIndex)->GetClassName());
- views::Label* label =
- static_cast<views::Label*>(selector->child_at(kLabelIndex));
- EXPECT_EQ(base::ASCIIToUTF16("Location"), label->text());
+ EXPECT_EQ(base::ASCIIToUTF16("Location"), api_->GetPermissionLabelTextAt(0));
EXPECT_EQ(base::ASCIIToUTF16("Allow"), api_->GetPermissionButtonTextAt(0));
// Verify calling SetPermisisonInfo() directly updates the UI.
@@ -221,7 +228,8 @@ TEST_F(WebsiteSettingsPopupViewTest, MAYBE_SetPermissionInfo) {
// Test UI construction and reconstruction with USB devices.
TEST_F(WebsiteSettingsPopupViewTest, SetPermissionInfoWithUsbDevice) {
const int kExpectedChildren =
- ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 11 : 13;
+ kViewsPerPermissionRow *
+ (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 11 : 13);
EXPECT_EQ(kExpectedChildren, api_->permissions_view()->child_count());
const GURL origin = GURL(kUrl).GetOrigin();
« no previous file with comments | « chrome/browser/ui/views/website_settings/website_settings_popup_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698