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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/widget/RadioButtonLayoutTest.java

Issue 2855913002: Revert of ❄ Split off RadioButtonLayout from InfoBarControls (Closed)
Patch Set: Created 3 years, 8 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/android/java_sources.gni ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/widget/RadioButtonLayoutTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/RadioButtonLayoutTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/widget/RadioButtonLayoutTest.java
deleted file mode 100644
index 927c06e291e773c941dd6fb6ef9283dcce4d8e42..0000000000000000000000000000000000000000
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/RadioButtonLayoutTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.widget;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.rule.UiThreadTestRule;
-import android.test.UiThreadTest;
-import android.view.View;
-import android.view.ViewGroup.MarginLayoutParams;
-import android.widget.RadioButton;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Tests for {@link RadioButtonLayout}.
- */
-@RunWith(ChromeJUnit4ClassRunner.class)
-public class RadioButtonLayoutTest {
- @Rule
- public UiThreadTestRule mRule = new UiThreadTestRule();
-
- private Context mContext;
-
- @Before
- public void setUp() {
- mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
- }
-
- @Test
- @SmallTest
- @UiThreadTest
- public void testMargins() {
- RadioButtonLayout layout = new RadioButtonLayout(mContext);
-
- // Add one set of options.
- List<CharSequence> messages = new ArrayList<CharSequence>();
- messages.add("a");
- messages.add("b");
- messages.add("c");
- layout.addOptions(messages, null);
-
- // Test the margins.
- for (int i = 0; i < layout.getChildCount(); i++) {
- View child = layout.getChildAt(i);
- MarginLayoutParams params = (MarginLayoutParams) child.getLayoutParams();
-
- if (i < layout.getChildCount() - 1) {
- Assert.assertNotEquals(0, params.bottomMargin);
- } else {
- Assert.assertEquals(0, params.bottomMargin);
- }
- }
-
- // Add more options.
- List<CharSequence> moreMessages = new ArrayList<CharSequence>();
- moreMessages.add("d");
- moreMessages.add("e");
- moreMessages.add("f");
- layout.addOptions(moreMessages, null);
-
- // Test the margins.
- for (int i = 0; i < layout.getChildCount(); i++) {
- View child = layout.getChildAt(i);
- MarginLayoutParams params = (MarginLayoutParams) child.getLayoutParams();
-
- if (i < layout.getChildCount() - 1) {
- Assert.assertNotEquals(0, params.bottomMargin);
- } else {
- Assert.assertEquals(0, params.bottomMargin);
- }
- }
- }
-
- @Test
- @SmallTest
- @UiThreadTest
- public void testAddOptions() {
- RadioButtonLayout layout = new RadioButtonLayout(mContext);
-
- // Add one set of options.
- List<CharSequence> messages = new ArrayList<CharSequence>();
- messages.add("a");
- messages.add("b");
- messages.add("c");
- List<String> tags = Arrays.asList("tag 1", "tag 2", "tag 3");
- layout.addOptions(messages, tags);
- Assert.assertEquals(3, layout.getChildCount());
- for (int i = 0; i < layout.getChildCount(); i++) {
- Assert.assertEquals(messages.get(i), ((RadioButton) layout.getChildAt(i)).getText());
- Assert.assertEquals(tags.get(i), ((RadioButton) layout.getChildAt(i)).getTag());
- }
-
- // Add even more options, but without tags.
- List<CharSequence> moreMessages = new ArrayList<CharSequence>();
- moreMessages.add("d");
- moreMessages.add("e");
- moreMessages.add("f");
- layout.addOptions(moreMessages, null);
- Assert.assertEquals(6, layout.getChildCount());
- for (int i = 0; i < 3; i++) {
- Assert.assertEquals(messages.get(i), ((RadioButton) layout.getChildAt(i)).getText());
- Assert.assertEquals(tags.get(i), ((RadioButton) layout.getChildAt(i)).getTag());
- }
- for (int i = 3; i < 6; i++) {
- Assert.assertEquals(
- moreMessages.get(i - 3), ((RadioButton) layout.getChildAt(i)).getText());
- Assert.assertNull(((RadioButton) layout.getChildAt(i)).getTag());
- }
- }
-
- @Test
- @SmallTest
- @UiThreadTest
- public void testSelection() {
- RadioButtonLayout layout = new RadioButtonLayout(mContext);
-
- // Add one set of options.
- List<CharSequence> messages = new ArrayList<CharSequence>();
- messages.add("a");
- messages.add("b");
- messages.add("c");
- layout.addOptions(messages, null);
- Assert.assertEquals(3, layout.getChildCount());
-
- // Nothing should be selected by default.
- for (int i = 0; i < layout.getChildCount(); i++) {
- RadioButton child = (RadioButton) layout.getChildAt(i);
- Assert.assertFalse(child.isChecked());
- }
-
- // Select the second one.
- layout.selectChildAtIndex(1);
- for (int i = 0; i < layout.getChildCount(); i++) {
- RadioButton child = (RadioButton) layout.getChildAt(i);
- Assert.assertEquals(i == 1, child.isChecked());
- }
-
- // Add even more options.
- List<CharSequence> moreMessages = new ArrayList<CharSequence>();
- moreMessages.add("d");
- moreMessages.add("e");
- moreMessages.add("f");
- layout.addOptions(moreMessages, null);
- Assert.assertEquals(6, layout.getChildCount());
-
- // Second child should still be checked.
- for (int i = 0; i < layout.getChildCount(); i++) {
- RadioButton child = (RadioButton) layout.getChildAt(i);
- Assert.assertEquals(i == 1, child.isChecked());
- }
- }
-}
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698