| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.widget; | 5 package org.chromium.chrome.browser.widget; |
| 6 | 6 |
| 7 import static org.chromium.chrome.browser.widget.DualControlLayout.ALIGN_APART; | 7 import static org.chromium.chrome.browser.widget.DualControlLayout.ALIGN_APART; |
| 8 import static org.chromium.chrome.browser.widget.DualControlLayout.ALIGN_END; | 8 import static org.chromium.chrome.browser.widget.DualControlLayout.ALIGN_END; |
| 9 import static org.chromium.chrome.browser.widget.DualControlLayout.ALIGN_START; | 9 import static org.chromium.chrome.browser.widget.DualControlLayout.ALIGN_START; |
| 10 | 10 |
| 11 import android.annotation.TargetApi; | 11 import android.annotation.TargetApi; |
| 12 import android.content.Context; | 12 import android.content.Context; |
| 13 import android.os.Build; | 13 import android.os.Build; |
| 14 import android.support.test.InstrumentationRegistry; |
| 15 import android.support.test.annotation.UiThreadTest; |
| 14 import android.support.test.filters.SmallTest; | 16 import android.support.test.filters.SmallTest; |
| 15 import android.test.InstrumentationTestCase; | 17 import android.support.test.rule.UiThreadTestRule; |
| 16 import android.test.MoreAsserts; | |
| 17 import android.test.UiThreadTest; | |
| 18 import android.view.LayoutInflater; | 18 import android.view.LayoutInflater; |
| 19 import android.view.View; | 19 import android.view.View; |
| 20 import android.view.View.MeasureSpec; | 20 import android.view.View.MeasureSpec; |
| 21 import android.view.ViewGroup.LayoutParams; | 21 import android.view.ViewGroup.LayoutParams; |
| 22 import android.widget.Button; | 22 import android.widget.Button; |
| 23 import android.widget.FrameLayout; | 23 import android.widget.FrameLayout; |
| 24 import android.widget.Space; | 24 import android.widget.Space; |
| 25 | 25 |
| 26 import org.junit.Assert; |
| 27 import org.junit.Before; |
| 28 import org.junit.Rule; |
| 29 import org.junit.Test; |
| 30 import org.junit.runner.RunWith; |
| 31 |
| 26 import org.chromium.base.test.util.MinAndroidSdkLevel; | 32 import org.chromium.base.test.util.MinAndroidSdkLevel; |
| 27 import org.chromium.chrome.R; | 33 import org.chromium.chrome.R; |
| 34 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| 28 | 35 |
| 29 /** | 36 /** |
| 30 * Tests for DualControlLayout. | 37 * Tests for DualControlLayout. |
| 31 */ | 38 */ |
| 32 public class DualControlLayoutTest extends InstrumentationTestCase { | 39 @RunWith(ChromeJUnit4ClassRunner.class) |
| 40 public class DualControlLayoutTest { |
| 33 private static final int PRIMARY_HEIGHT = 16; | 41 private static final int PRIMARY_HEIGHT = 16; |
| 34 private static final int SECONDARY_HEIGHT = 8; | 42 private static final int SECONDARY_HEIGHT = 8; |
| 35 private static final int STACKED_MARGIN = 4; | 43 private static final int STACKED_MARGIN = 4; |
| 36 private static final int INFOBAR_WIDTH = 3200; | 44 private static final int INFOBAR_WIDTH = 3200; |
| 37 | 45 |
| 38 private static final int PADDING_LEFT = 8; | 46 private static final int PADDING_LEFT = 8; |
| 39 private static final int PADDING_TOP = 16; | 47 private static final int PADDING_TOP = 16; |
| 40 private static final int PADDING_RIGHT = 32; | 48 private static final int PADDING_RIGHT = 32; |
| 41 private static final int PADDING_BOTTOM = 64; | 49 private static final int PADDING_BOTTOM = 64; |
| 42 | 50 |
| 43 private int mTinyControlWidth; | 51 private int mTinyControlWidth; |
| 44 private Context mContext; | 52 private Context mContext; |
| 45 | 53 |
| 46 @Override | 54 @Rule |
| 55 public UiThreadTestRule mRule = new UiThreadTestRule(); |
| 56 |
| 57 @Before |
| 47 public void setUp() throws Exception { | 58 public void setUp() throws Exception { |
| 48 super.setUp(); | 59 mContext = InstrumentationRegistry.getInstrumentation().getTargetContext
(); |
| 49 mContext = getInstrumentation().getTargetContext(); | |
| 50 mContext.setTheme(R.style.MainTheme); | 60 mContext.setTheme(R.style.MainTheme); |
| 51 mTinyControlWidth = INFOBAR_WIDTH / 4; | 61 mTinyControlWidth = INFOBAR_WIDTH / 4; |
| 52 } | 62 } |
| 53 | 63 |
| 64 @Test |
| 54 @SmallTest | 65 @SmallTest |
| 55 @UiThreadTest | 66 @UiThreadTest |
| 56 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) | 67 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) |
| 57 @MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN_MR1) | 68 @MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN_MR1) |
| 58 public void testAlignSideBySide() { | 69 public void testAlignSideBySide() { |
| 59 runLayoutTest(ALIGN_START, false, false, false); | 70 runLayoutTest(ALIGN_START, false, false, false); |
| 60 runLayoutTest(ALIGN_START, false, true, false); | 71 runLayoutTest(ALIGN_START, false, true, false); |
| 61 runLayoutTest(ALIGN_START, true, false, false); | 72 runLayoutTest(ALIGN_START, true, false, false); |
| 62 runLayoutTest(ALIGN_START, true, true, false); | 73 runLayoutTest(ALIGN_START, true, true, false); |
| 63 | 74 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // Trigger the measurement & layout algorithms. | 126 // Trigger the measurement & layout algorithms. |
| 116 int parentWidthSpec = MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, Measure
Spec.EXACTLY); | 127 int parentWidthSpec = MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, Measure
Spec.EXACTLY); |
| 117 int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPEC
IFIED); | 128 int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPEC
IFIED); |
| 118 layout.measure(parentWidthSpec, parentHeightSpec); | 129 layout.measure(parentWidthSpec, parentHeightSpec); |
| 119 layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight(
)); | 130 layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight(
)); |
| 120 | 131 |
| 121 // Confirm that the primary View is in the correct place. | 132 // Confirm that the primary View is in the correct place. |
| 122 if ((isRtl && alignment == ALIGN_START) | 133 if ((isRtl && alignment == ALIGN_START) |
| 123 || (!isRtl && (alignment == ALIGN_APART || alignment == ALIGN_EN
D))) { | 134 || (!isRtl && (alignment == ALIGN_APART || alignment == ALIGN_EN
D))) { |
| 124 int expectedRight = INFOBAR_WIDTH - (addPadding ? PADDING_RIGHT : 0)
; | 135 int expectedRight = INFOBAR_WIDTH - (addPadding ? PADDING_RIGHT : 0)
; |
| 125 assertEquals("Primary should be on the right.", expectedRight, prima
ry.getRight()); | 136 Assert.assertEquals( |
| 137 "Primary should be on the right.", expectedRight, primary.ge
tRight()); |
| 126 } else { | 138 } else { |
| 127 int expectedLeft = addPadding ? PADDING_LEFT : 0; | 139 int expectedLeft = addPadding ? PADDING_LEFT : 0; |
| 128 assertEquals("Primary should be on the left.", expectedLeft, primary
.getLeft()); | 140 Assert.assertEquals("Primary should be on the left.", expectedLeft,
primary.getLeft()); |
| 129 } | 141 } |
| 130 int expectedTop = addPadding ? PADDING_TOP : 0; | 142 int expectedTop = addPadding ? PADDING_TOP : 0; |
| 131 int expectedBottom = expectedTop + PRIMARY_HEIGHT; | 143 int expectedBottom = expectedTop + PRIMARY_HEIGHT; |
| 132 assertEquals("Primary top in wrong location", expectedTop, primary.getTo
p()); | 144 Assert.assertEquals("Primary top in wrong location", expectedTop, primar
y.getTop()); |
| 133 assertEquals("Primary bottom in wrong location", expectedBottom, primary
.getBottom()); | 145 Assert.assertEquals( |
| 134 assertEquals(mTinyControlWidth, primary.getMeasuredWidth()); | 146 "Primary bottom in wrong location", expectedBottom, primary.getB
ottom()); |
| 135 assertEquals(PRIMARY_HEIGHT, primary.getMeasuredHeight()); | 147 Assert.assertEquals(mTinyControlWidth, primary.getMeasuredWidth()); |
| 136 MoreAsserts.assertNotEqual(primary.getLeft(), primary.getRight()); | 148 Assert.assertEquals(PRIMARY_HEIGHT, primary.getMeasuredHeight()); |
| 149 Assert.assertNotEquals(primary.getLeft(), primary.getRight()); |
| 137 | 150 |
| 138 // Confirm that the secondary View is in the correct place. | 151 // Confirm that the secondary View is in the correct place. |
| 139 if (secondary != null) { | 152 if (secondary != null) { |
| 140 assertEquals(mTinyControlWidth, secondary.getMeasuredWidth()); | 153 Assert.assertEquals(mTinyControlWidth, secondary.getMeasuredWidth())
; |
| 141 assertEquals(SECONDARY_HEIGHT, secondary.getMeasuredHeight()); | 154 Assert.assertEquals(SECONDARY_HEIGHT, secondary.getMeasuredHeight())
; |
| 142 MoreAsserts.assertNotEqual(secondary.getLeft(), secondary.getRight()
); | 155 Assert.assertNotEquals(secondary.getLeft(), secondary.getRight()); |
| 143 if (alignment == ALIGN_START) { | 156 if (alignment == ALIGN_START) { |
| 144 if (isRtl) { | 157 if (isRtl) { |
| 145 // Secondary View is immediately to the left of the parent. | 158 // Secondary View is immediately to the left of the parent. |
| 146 assertTrue(secondary.getRight() < primary.getLeft()); | 159 Assert.assertTrue(secondary.getRight() < primary.getLeft()); |
| 147 MoreAsserts.assertNotEqual(0, secondary.getLeft()); | 160 Assert.assertNotEquals(0, secondary.getLeft()); |
| 148 } else { | 161 } else { |
| 149 // Secondary View is immediately to the right of the parent. | 162 // Secondary View is immediately to the right of the parent. |
| 150 assertTrue(primary.getRight() < secondary.getLeft()); | 163 Assert.assertTrue(primary.getRight() < secondary.getLeft()); |
| 151 MoreAsserts.assertNotEqual(INFOBAR_WIDTH, secondary.getRight
()); | 164 Assert.assertNotEquals(INFOBAR_WIDTH, secondary.getRight()); |
| 152 } | 165 } |
| 153 } else if (alignment == ALIGN_APART) { | 166 } else if (alignment == ALIGN_APART) { |
| 154 if (isRtl) { | 167 if (isRtl) { |
| 155 // Secondary View is on the far right. | 168 // Secondary View is on the far right. |
| 156 assertTrue(primary.getRight() < secondary.getLeft()); | 169 Assert.assertTrue(primary.getRight() < secondary.getLeft()); |
| 157 int expectedRight = INFOBAR_WIDTH - (addPadding ? PADDING_RI
GHT : 0); | 170 int expectedRight = INFOBAR_WIDTH - (addPadding ? PADDING_RI
GHT : 0); |
| 158 assertEquals(expectedRight, secondary.getRight()); | 171 Assert.assertEquals(expectedRight, secondary.getRight()); |
| 159 } else { | 172 } else { |
| 160 // Secondary View is on the far left. | 173 // Secondary View is on the far left. |
| 161 assertTrue(secondary.getRight() < primary.getLeft()); | 174 Assert.assertTrue(secondary.getRight() < primary.getLeft()); |
| 162 int expectedLeft = addPadding ? PADDING_LEFT : 0; | 175 int expectedLeft = addPadding ? PADDING_LEFT : 0; |
| 163 assertEquals(expectedLeft, secondary.getLeft()); | 176 Assert.assertEquals(expectedLeft, secondary.getLeft()); |
| 164 } | 177 } |
| 165 } else { | 178 } else { |
| 166 assertEquals(ALIGN_END, alignment); | 179 Assert.assertEquals(ALIGN_END, alignment); |
| 167 if (isRtl) { | 180 if (isRtl) { |
| 168 // Secondary View is immediately to the right of the parent. | 181 // Secondary View is immediately to the right of the parent. |
| 169 assertTrue(primary.getRight() < secondary.getLeft()); | 182 Assert.assertTrue(primary.getRight() < secondary.getLeft()); |
| 170 MoreAsserts.assertNotEqual(INFOBAR_WIDTH, secondary.getRight
()); | 183 Assert.assertNotEquals(INFOBAR_WIDTH, secondary.getRight()); |
| 171 } else { | 184 } else { |
| 172 // Secondary View is immediately to the left of the parent. | 185 // Secondary View is immediately to the left of the parent. |
| 173 assertTrue(secondary.getRight() < primary.getLeft()); | 186 Assert.assertTrue(secondary.getRight() < primary.getLeft()); |
| 174 MoreAsserts.assertNotEqual(0, secondary.getLeft()); | 187 Assert.assertNotEquals(0, secondary.getLeft()); |
| 175 } | 188 } |
| 176 } | 189 } |
| 177 | 190 |
| 178 // Confirm that the secondary View is centered with respect to the f
irst. | 191 // Confirm that the secondary View is centered with respect to the f
irst. |
| 179 int primaryCenter = (primary.getTop() + primary.getBottom()) / 2; | 192 int primaryCenter = (primary.getTop() + primary.getBottom()) / 2; |
| 180 int secondaryCenter = (secondary.getTop() + secondary.getBottom()) /
2; | 193 int secondaryCenter = (secondary.getTop() + secondary.getBottom()) /
2; |
| 181 assertEquals(primaryCenter, secondaryCenter); | 194 Assert.assertEquals(primaryCenter, secondaryCenter); |
| 182 } | 195 } |
| 183 | 196 |
| 184 int expectedLayoutHeight = | 197 int expectedLayoutHeight = |
| 185 primary.getMeasuredHeight() + (addPadding ? PADDING_TOP + PADDIN
G_BOTTOM : 0); | 198 primary.getMeasuredHeight() + (addPadding ? PADDING_TOP + PADDIN
G_BOTTOM : 0); |
| 186 assertEquals(expectedLayoutHeight, layout.getMeasuredHeight()); | 199 Assert.assertEquals(expectedLayoutHeight, layout.getMeasuredHeight()); |
| 187 } | 200 } |
| 188 | 201 |
| 202 @Test |
| 189 @SmallTest | 203 @SmallTest |
| 190 @UiThreadTest | 204 @UiThreadTest |
| 191 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) | 205 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) |
| 192 public void testStacked() { | 206 public void testStacked() { |
| 193 runStackedLayoutTest(ALIGN_START, false, false); | 207 runStackedLayoutTest(ALIGN_START, false, false); |
| 194 runStackedLayoutTest(ALIGN_START, true, false); | 208 runStackedLayoutTest(ALIGN_START, true, false); |
| 195 runStackedLayoutTest(ALIGN_APART, false, false); | 209 runStackedLayoutTest(ALIGN_APART, false, false); |
| 196 runStackedLayoutTest(ALIGN_APART, true, false); | 210 runStackedLayoutTest(ALIGN_APART, true, false); |
| 197 runStackedLayoutTest(ALIGN_END, false, false); | 211 runStackedLayoutTest(ALIGN_END, false, false); |
| 198 runStackedLayoutTest(ALIGN_END, true, false); | 212 runStackedLayoutTest(ALIGN_END, true, false); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 227 secondary.setMinimumHeight(SECONDARY_HEIGHT); | 241 secondary.setMinimumHeight(SECONDARY_HEIGHT); |
| 228 layout.addView(secondary); | 242 layout.addView(secondary); |
| 229 | 243 |
| 230 // Trigger the measurement & layout algorithms. | 244 // Trigger the measurement & layout algorithms. |
| 231 int parentWidthSpec = | 245 int parentWidthSpec = |
| 232 MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST); | 246 MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST); |
| 233 int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPEC
IFIED); | 247 int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPEC
IFIED); |
| 234 layout.measure(parentWidthSpec, parentHeightSpec); | 248 layout.measure(parentWidthSpec, parentHeightSpec); |
| 235 layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight(
)); | 249 layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight(
)); |
| 236 | 250 |
| 237 assertEquals(addPadding ? PADDING_LEFT : 0, primary.getLeft()); | 251 Assert.assertEquals(addPadding ? PADDING_LEFT : 0, primary.getLeft()); |
| 238 assertEquals(addPadding ? PADDING_LEFT : 0, secondary.getLeft()); | 252 Assert.assertEquals(addPadding ? PADDING_LEFT : 0, secondary.getLeft()); |
| 239 | 253 |
| 240 assertEquals(INFOBAR_WIDTH - (addPadding ? PADDING_RIGHT : 0), primary.g
etRight()); | 254 Assert.assertEquals(INFOBAR_WIDTH - (addPadding ? PADDING_RIGHT : 0), pr
imary.getRight()); |
| 241 assertEquals(INFOBAR_WIDTH - (addPadding ? PADDING_RIGHT : 0), secondary
.getRight()); | 255 Assert.assertEquals(INFOBAR_WIDTH - (addPadding ? PADDING_RIGHT : 0), se
condary.getRight()); |
| 242 | 256 |
| 243 int expectedControlWidth = INFOBAR_WIDTH - (addPadding ? PADDING_LEFT +
PADDING_RIGHT : 0); | 257 int expectedControlWidth = INFOBAR_WIDTH - (addPadding ? PADDING_LEFT +
PADDING_RIGHT : 0); |
| 244 assertEquals(expectedControlWidth, primary.getMeasuredWidth()); | 258 Assert.assertEquals(expectedControlWidth, primary.getMeasuredWidth()); |
| 245 assertEquals(expectedControlWidth, secondary.getMeasuredWidth()); | 259 Assert.assertEquals(expectedControlWidth, secondary.getMeasuredWidth()); |
| 246 assertEquals(INFOBAR_WIDTH, layout.getMeasuredWidth()); | 260 Assert.assertEquals(INFOBAR_WIDTH, layout.getMeasuredWidth()); |
| 247 | 261 |
| 248 int expectedPrimaryTop = addPadding ? PADDING_TOP : 0; | 262 int expectedPrimaryTop = addPadding ? PADDING_TOP : 0; |
| 249 int expectedPrimaryBottom = expectedPrimaryTop + primary.getHeight(); | 263 int expectedPrimaryBottom = expectedPrimaryTop + primary.getHeight(); |
| 250 int expectedSecondaryTop = expectedPrimaryBottom + STACKED_MARGIN; | 264 int expectedSecondaryTop = expectedPrimaryBottom + STACKED_MARGIN; |
| 251 int expectedSecondaryBottom = expectedSecondaryTop + secondary.getHeight
(); | 265 int expectedSecondaryBottom = expectedSecondaryTop + secondary.getHeight
(); |
| 252 int expectedLayoutHeight = expectedSecondaryBottom + (addPadding ? PADDI
NG_BOTTOM : 0); | 266 int expectedLayoutHeight = expectedSecondaryBottom + (addPadding ? PADDI
NG_BOTTOM : 0); |
| 253 assertEquals(expectedPrimaryTop, primary.getTop()); | 267 Assert.assertEquals(expectedPrimaryTop, primary.getTop()); |
| 254 assertEquals(expectedPrimaryBottom, primary.getBottom()); | 268 Assert.assertEquals(expectedPrimaryBottom, primary.getBottom()); |
| 255 assertEquals(expectedSecondaryTop, secondary.getTop()); | 269 Assert.assertEquals(expectedSecondaryTop, secondary.getTop()); |
| 256 assertEquals(expectedSecondaryBottom, secondary.getBottom()); | 270 Assert.assertEquals(expectedSecondaryBottom, secondary.getBottom()); |
| 257 assertEquals(expectedLayoutHeight, layout.getMeasuredHeight()); | 271 Assert.assertEquals(expectedLayoutHeight, layout.getMeasuredHeight()); |
| 258 MoreAsserts.assertNotEqual(layout.getMeasuredHeight(), primary.getMeasur
edHeight()); | 272 Assert.assertNotEquals(layout.getMeasuredHeight(), primary.getMeasuredHe
ight()); |
| 259 } | 273 } |
| 260 | 274 |
| 261 /** | 275 /** |
| 262 * Runs a test against an inflated DualControlLayout that sets all of its va
lues. | 276 * Runs a test against an inflated DualControlLayout that sets all of its va
lues. |
| 263 * Re-uses the AutofillEditor's buttons XML layout because we have no suppor
t for test-only | 277 * Re-uses the AutofillEditor's buttons XML layout because we have no suppor
t for test-only |
| 264 * layout files. | 278 * layout files. |
| 265 */ | 279 */ |
| 280 @Test |
| 266 @SmallTest | 281 @SmallTest |
| 267 @UiThreadTest | 282 @UiThreadTest |
| 268 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) | 283 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) |
| 269 @MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN_MR1) | 284 @MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN_MR1) |
| 270 public void testInflation() { | 285 public void testInflation() { |
| 271 // Check that the basic DualControlLayout has nothing going on. | 286 // Check that the basic DualControlLayout has nothing going on. |
| 272 DualControlLayout layout = new DualControlLayout(mContext, null); | 287 DualControlLayout layout = new DualControlLayout(mContext, null); |
| 273 assertEquals(DualControlLayout.ALIGN_START, layout.getAlignment()); | 288 Assert.assertEquals(DualControlLayout.ALIGN_START, layout.getAlignment()
); |
| 274 assertEquals(0, layout.getStackedMargin()); | 289 Assert.assertEquals(0, layout.getStackedMargin()); |
| 275 assertNull(layout.findViewById(R.id.button_primary)); | 290 Assert.assertNull(layout.findViewById(R.id.button_primary)); |
| 276 assertNull(layout.findViewById(R.id.button_secondary)); | 291 Assert.assertNull(layout.findViewById(R.id.button_secondary)); |
| 277 | 292 |
| 278 // Inflate a DualControlLayout that has all of the attributes set and co
nfirm they're used | 293 // Inflate a DualControlLayout that has all of the attributes set and co
nfirm they're used |
| 279 // correctly. | 294 // correctly. |
| 280 FrameLayout containerView = new FrameLayout(mContext); | 295 FrameLayout containerView = new FrameLayout(mContext); |
| 281 LayoutInflater.from(mContext).inflate( | 296 LayoutInflater.from(mContext).inflate( |
| 282 R.layout.autofill_editor_base_buttons, containerView, true); | 297 R.layout.autofill_editor_base_buttons, containerView, true); |
| 283 DualControlLayout inflatedLayout = | 298 DualControlLayout inflatedLayout = |
| 284 (DualControlLayout) containerView.findViewById(R.id.button_bar); | 299 (DualControlLayout) containerView.findViewById(R.id.button_bar); |
| 285 assertEquals(DualControlLayout.ALIGN_END, inflatedLayout.getAlignment())
; | 300 Assert.assertEquals(DualControlLayout.ALIGN_END, inflatedLayout.getAlign
ment()); |
| 286 assertEquals(mContext.getResources().getDimensionPixelSize( | 301 Assert.assertEquals(mContext.getResources().getDimensionPixelSize( |
| 287 R.dimen.infobar_margin_between_stacked_buttons), | 302 R.dimen.infobar_margin_between_stacked_butto
ns), |
| 288 inflatedLayout.getStackedMargin()); | 303 inflatedLayout.getStackedMargin()); |
| 289 | 304 |
| 290 Button primaryButton = (Button) inflatedLayout.findViewById(R.id.button_
primary); | 305 Button primaryButton = (Button) inflatedLayout.findViewById(R.id.button_
primary); |
| 291 assertNotNull(primaryButton); | 306 Assert.assertNotNull(primaryButton); |
| 292 assertEquals(mContext.getString(R.string.done), primaryButton.getText())
; | 307 Assert.assertEquals(mContext.getString(R.string.done), primaryButton.get
Text()); |
| 293 | 308 |
| 294 Button secondaryButton = (Button) inflatedLayout.findViewById(R.id.butto
n_secondary); | 309 Button secondaryButton = (Button) inflatedLayout.findViewById(R.id.butto
n_secondary); |
| 295 assertNotNull(secondaryButton); | 310 Assert.assertNotNull(secondaryButton); |
| 296 assertEquals(mContext.getString(R.string.cancel), secondaryButton.getTex
t()); | 311 Assert.assertEquals(mContext.getString(R.string.cancel), secondaryButton
.getText()); |
| 297 } | 312 } |
| 298 } | 313 } |
| OLD | NEW |