Merge pull request #2361 from ngbravo/remove-put-RoboAttributeSet

RoboAttributeSet API changes
diff --git a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/fakes/RoboAttributeSet.java b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/fakes/RoboAttributeSet.java
index 7747a90..8a6f790 100644
--- a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/fakes/RoboAttributeSet.java
+++ b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/fakes/RoboAttributeSet.java
@@ -27,20 +27,22 @@
   private final List<Attribute> attributes;
   private final ResourceLoader resourceLoader;
 
-  public RoboAttributeSet(List<Attribute> attributes, ResourceLoader resourceLoader) {
+  private RoboAttributeSet(List<Attribute> attributes, ResourceLoader resourceLoader) {
     this.attributes = attributes;
     this.resourceLoader = resourceLoader;
   }
 
-  @Deprecated
-  public RoboAttributeSet put(String fullyQualifiedName, String value, String valuePackage) {
-    return put(new Attribute(fullyQualifiedName, value, valuePackage));
+  /**
+   * Creates a {@link RoboAttributeSet} as {@link AttributeSet} for the given
+   * {@link Context} and {@link Attribute}(s)
+   */
+  public static AttributeSet create(Context context, Attribute... attrs) {
+    List<Attribute> attributesList = Lists.newArrayList(attrs);
+    return create(context, attributesList);
   }
 
-  @Deprecated
-  public RoboAttributeSet put(Attribute attribute) {
-    attributes.add(attribute);
-    return this;
+  public static AttributeSet create(Context context, List<Attribute> attributesList) {
+    return new RoboAttributeSet(attributesList, shadowOf(context.getAssets()).getResourceLoader());
   }
 
   @Override
@@ -202,15 +204,6 @@
     return i != null ? i : 0;
   }
 
-  /**
-   * Creates a {@link RoboAttributeSet} for the given {@link Attribute}(s)
-   */
-  public static RoboAttributeSet create(Context context, Attribute... attrs) {
-    List<Attribute> attributesList = Lists.newArrayList(attrs);
-    return new RoboAttributeSet(attributesList,
-        shadowOf(context.getAssets()).getResourceLoader());
-  }
-
   private ResName getAttrResName(String namespace, String attrName) {
     String packageName = Attribute.extractPackageName(namespace);
     return new ResName(packageName, "attr", attrName);
diff --git a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowContext.java b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowContext.java
index 440df29..0166f98 100644
--- a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowContext.java
+++ b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowContext.java
@@ -2,20 +2,16 @@
 
 import android.content.Context;
 import android.os.Environment;
-import android.view.View;
 
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 import org.robolectric.annotation.RealObject;
-import org.robolectric.fakes.RoboAttributeSet;
-import org.robolectric.res.Attribute;
 import org.robolectric.res.ResName;
 import org.robolectric.res.ResourceLoader;
 import org.robolectric.util.ReflectionHelpers;
 import org.robolectric.util.ReflectionHelpers.ClassParameter;
 
 import java.io.File;
-import java.util.List;
 
 import static org.robolectric.Shadows.shadowOf;
 
@@ -28,10 +24,6 @@
   @RealObject private Context realContext;
   private ShadowApplication shadowApplication;
 
-  public RoboAttributeSet createAttributeSet(List<Attribute> attributes, Class<? extends View> viewClass) {
-    return new RoboAttributeSet(attributes, shadowOf(realContext.getAssets()).getResourceLoader());
-  }
-
   @Implementation
   public File getExternalCacheDir() {
     return Environment.getExternalStorageDirectory();
diff --git a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowResources.java b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowResources.java
index 3b360b2..b125f57 100644
--- a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowResources.java
+++ b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowResources.java
@@ -101,7 +101,7 @@
 
   private TypedArray attrsToTypedArray(AttributeSet set, int[] attrs, int defStyleAttr, int themeResourceId, int defStyleRes) {
     if (set == null) {
-      set = new RoboAttributeSet(new ArrayList<Attribute>(), shadowOf(realResources.getAssets()).getResourceLoader());
+      set = RoboAttributeSet.create(RuntimeEnvironment.application);
     }
 
     List<Attribute> attributes = shadowOf(realResources.getAssets()).buildAttributes(set, attrs, defStyleAttr, themeResourceId, defStyleRes);
diff --git a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/util/PreferenceBuilder.java b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/util/PreferenceBuilder.java
index 2b236d7..0a9aa44 100644
--- a/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/util/PreferenceBuilder.java
+++ b/robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/util/PreferenceBuilder.java
@@ -9,13 +9,13 @@
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceGroup;
 import android.util.AttributeSet;
+
+import org.robolectric.fakes.RoboAttributeSet;
 import org.robolectric.res.Attribute;
 import org.robolectric.res.PreferenceNode;
 import org.robolectric.res.ResName;
-import org.robolectric.fakes.RoboAttributeSet;
 
 import java.lang.reflect.InvocationTargetException;
-import java.util.List;
 
 import static org.robolectric.Shadows.shadowOf;
 
@@ -56,9 +56,7 @@
 
   private Preference constructPreference(PreferenceNode preferenceNode, Context context) {
     Class<? extends Preference> clazz = pickViewClass(preferenceNode);
-
-    List<Attribute> attributes = preferenceNode.getAttributes();
-    RoboAttributeSet attributeSet = shadowOf(context).createAttributeSet(attributes, null);
+    AttributeSet attributeSet = RoboAttributeSet.create(context, preferenceNode.getAttributes());
 
     try {
       try {
diff --git a/robolectric-shadows/shadows-maps/src/main/java/org/robolectric/shadows/maps/ShadowMapView.java b/robolectric-shadows/shadows-maps/src/main/java/org/robolectric/shadows/maps/ShadowMapView.java
index 202afdd..9b6edfd 100644
--- a/robolectric-shadows/shadows-maps/src/main/java/org/robolectric/shadows/maps/ShadowMapView.java
+++ b/robolectric-shadows/shadows-maps/src/main/java/org/robolectric/shadows/maps/ShadowMapView.java
@@ -18,9 +18,8 @@
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 import org.robolectric.annotation.RealObject;
-import org.robolectric.internal.Shadow;
-import org.robolectric.res.Attribute;
 import org.robolectric.fakes.RoboAttributeSet;
+import org.robolectric.internal.Shadow;
 import org.robolectric.shadows.ShadowViewGroup;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -30,7 +29,6 @@
 import static org.robolectric.internal.Shadow.directlyOn;
 import static org.robolectric.internal.Shadow.invokeConstructor;
 import static org.robolectric.shadows.maps.Shadows.shadowOf;
-import static org.robolectric.Shadows.shadowOf;
 import static org.robolectric.util.ReflectionHelpers.ClassParameter;
 
 /**
@@ -59,7 +57,7 @@
   @HiddenApi
   public void __constructor__(Context context) {
     setContextOnRealView(context);
-    this.attributeSet = new RoboAttributeSet(new ArrayList<Attribute>(), shadowOf(context.getAssets()).getResourceLoader());
+    this.attributeSet = RoboAttributeSet.create(context);
     zoomButtonsController = new ZoomButtonsController(realMapView);
     invokeConstructor(View.class, realView, ClassParameter.from(Context.class, context));
     invokeConstructor(ViewGroup.class, realView, ClassParameter.from(Context.class, context));
diff --git a/robolectric/src/test/java/org/robolectric/fakes/RoboAttributeSetTest.java b/robolectric/src/test/java/org/robolectric/fakes/RoboAttributeSetTest.java
index c7e778a..63a43db 100644
--- a/robolectric/src/test/java/org/robolectric/fakes/RoboAttributeSetTest.java
+++ b/robolectric/src/test/java/org/robolectric/fakes/RoboAttributeSetTest.java
@@ -1,6 +1,7 @@
 package org.robolectric.fakes;
 
 import android.content.Context;
+import android.util.AttributeSet;
 import android.view.Gravity;
 
 import org.junit.Before;
@@ -11,11 +12,10 @@
 import org.robolectric.TestRunners;
 import org.robolectric.res.Attribute;
 import org.robolectric.res.ResName;
-import org.robolectric.res.ResourceLoader;
 
-import static java.util.Arrays.asList;
+import java.util.ArrayList;
+
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.robolectric.Shadows.shadowOf;
 import static org.robolectric.res.Attribute.ANDROID_RES_NS_PREFIX;
 import static org.robolectric.res.ResourceLoader.ANDROID_NS;
 import static org.robolectric.util.TestUtil.SYSTEM_PACKAGE;
@@ -24,269 +24,323 @@
 
 @RunWith(TestRunners.WithDefaults.class)
 public class RoboAttributeSetTest {
-  private RoboAttributeSet roboAttributeSet;
-  private ResourceLoader resourceLoader;
+  private AttributeSet roboAttributeSet;
+  private Context context;
 
   @Before
   public void setUp() throws Exception {
-    resourceLoader = shadowOf(RuntimeEnvironment.application.getAssets()).getResourceLoader();
+    context = RuntimeEnvironment.application;
   }
 
   @Test
   public void getSystemAttributeResourceValue_shouldReturnTheResourceValue() throws Exception {
-    createTestAttributeSet(new Attribute("android:attr/text", "@android:string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("android:attr/text", "@android:string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_NS, "text", 0)).isEqualTo(android.R.string.ok);
   }
 
   @Test
   public void getAttributeResourceValue_shouldReturnTheResourceValue() throws Exception {
-    createTestAttributeSet(new Attribute("android:attr/text", "@string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("android:attr/text", "@string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_NS, "text", 0)).isEqualTo(R.string.ok);
   }
 
   @Test
   public void getSystemAttributeResourceValueWithLeadingWhitespace_shouldReturnTheResourceValue() throws Exception {
-    createTestAttributeSet(new Attribute("android:attr/text", " @android:string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("android:attr/text", " @android:string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_NS, "text", 0)).isEqualTo(android.R.string.ok);
   }
 
   @Test
   public void getAttributeResourceValueWithLeadingWhitespace_shouldReturnTheResourceValue() throws Exception {
-    createTestAttributeSet(new Attribute("android:attr/text", " @string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("android:attr/text", " @string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_NS, "text", 0)).isEqualTo(R.string.ok);
   }
 
   @Test
   public void getSystemAttributeResourceValue_shouldNotReturnTheResourceValueIfNameSpaceDoesNotMatch() throws Exception {
-    createTestAttributeSet(new Attribute("com.another.domain:attr/text", "@android:string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("com.another.domain:attr/text", "@android:string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_NS, "text", 0)).isEqualTo(0);
   }
 
   @Test
   public void getAttributeResourceValue_shouldReturnTheResourceValueFromSystemNamespace() throws Exception {
-    createTestAttributeSet(new Attribute("com.another.domain:attr/text", "@android:string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("com.another.domain:attr/text", "@android:string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_RES_NS_PREFIX + "com.another.domain", "text", 0)).isEqualTo(android.R.string.ok);
   }
 
   @Test
   public void getSystemAttributeResourceValue_shouldReturnDefaultValueForNullResourceId() throws Exception {
-    createTestAttributeSet(new Attribute("android:attr/text", "@null", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("android:attr/text", "@null", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_RES_NS_PREFIX + "com.some.namespace", "text", 0)).isEqualTo(0);
   }
 
   @Test
   public void getSystemAttributeResourceValue_shouldReturnValueForMatchingNamespace() throws Exception {
-    createTestAttributeSet(new Attribute("com.some.namespace:attr/id", "@id/burritos", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("com.some.namespace:attr/id", "@id/burritos", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_RES_NS_PREFIX + "com.some.namespace", "id", 0)).isEqualTo(R.id.burritos);
   }
 
   @Test
   public void getSystemAttributeResourceValue_shouldReturnDefaultValueForNonMatchingNamespaceId() throws Exception {
-    createTestAttributeSet(new Attribute("com.some.namespace:attr/id", "@id/burritos", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("com.some.namespace:attr/id", "@id/burritos", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_RES_NS_PREFIX + "com.some.other.namespace", "id", 0)).isEqualTo(0);
   }
 
   @Test
   public void shouldCopeWithDefiningSystemIds() throws Exception {
-    createTestAttributeSet(new Attribute("android:attr/id", "@+id/text1", SYSTEM_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("android:attr/id", "@+id/text1", SYSTEM_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_NS, "id", 0)).isEqualTo(android.R.id.text1);
   }
 
   @Test
   public void shouldCopeWithDefiningLocalIds() throws Exception {
-    createTestAttributeSet(new Attribute("android:attr/id", "@+id/text1", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("android:attr/id", "@+id/text1", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(ANDROID_NS, "id", 0)).isEqualTo(R.id.text1);
   }
 
   @Test
   public void getAttributeResourceValue_withNamespace_shouldReturnTheResourceValue() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/message", "@string/howdy", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/message", "@string/howdy", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(TEST_PACKAGE_NS, "message", 0)).isEqualTo(R.string.howdy);
   }
 
   @Test
   public void getAttributeResourceValue_shouldReturnDefaultValueWhenAttributeIsNull() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/message", "@null", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/message", "@null", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeResourceValue(TEST_PACKAGE_NS, "message", -1)).isEqualTo(-1);
   }
 
   @Test
   public void getAttributeResourceValue_shouldReturnDefaultValueWhenNotInAttributeSet() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     assertThat(roboAttributeSet.getAttributeResourceValue(TEST_PACKAGE_NS, "message", -1)).isEqualTo(-1);
   }
 
   @Test
   public void getAttributeBooleanValue_shouldGetBooleanValuesFromAttributes() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/isSugary", "true", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/isSugary", "true", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeBooleanValue(TEST_PACKAGE_NS, "isSugary", false)).isTrue();
   }
 
   @Test
   public void getAttributeBooleanValue_withNamespace_shouldGetBooleanValuesFromAttributes() throws Exception {
-    createTestAttributeSet(new Attribute("xxx:attr/isSugary", "true", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("xxx:attr/isSugary", "true", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeBooleanValue(ANDROID_RES_NS_PREFIX + "xxx", "isSugary", false)).isTrue();
   }
 
   @Test
   public void getAttributeBooleanValue_shouldReturnDefaultBooleanValueWhenNotInAttributeSet() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     assertThat(roboAttributeSet.getAttributeBooleanValue(ANDROID_RES_NS_PREFIX + "com.some.namespace", "isSugary", true)).isTrue();
   }
 
   @Test
   public void getAttributeValue_byName_shouldReturnValueFromAttribute() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/isSugary", "oh heck yeah", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/isSugary", "oh heck yeah", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeValue(TEST_PACKAGE_NS, "isSugary")).isEqualTo("oh heck yeah");
   }
 
   @Test
   public void getAttributeValue_byNameWithReference_shouldReturnFullyQualifiedValueFromAttribute() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/isSugary", "@string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/isSugary", "@string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeValue(TEST_PACKAGE_NS, "isSugary")).isEqualTo("@org.robolectric:string/ok");
   }
 
   @Test
   public void getAttributeValue_byId_shouldReturnValueFromAttribute() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/isSugary", "oh heck yeah", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/isSugary", "oh heck yeah", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeValue(0)).isEqualTo("oh heck yeah");
   }
 
   @Test
   public void getAttributeValue_byIdWithReference_shouldReturnValueFromAttribute() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/isSugary", "@string/ok", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/isSugary", "@string/ok", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeValue(0)).isEqualTo("@org.robolectric:string/ok");
   }
 
   @Test
   public void getAttributeIntValue_shouldReturnValueFromAttribute() throws Exception {
-    roboAttributeSet = new RoboAttributeSet(asList(new Attribute(TEST_PACKAGE + ":attr/sugarinessPercent", "100", TEST_PACKAGE)),
-        resourceLoader);
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/sugarinessPercent", "100", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "sugarinessPercent", 0)).isEqualTo(100);
   }
 
   @Test
   public void getAttributeIntValue_shouldReturnHexValueFromAttribute() throws Exception {
-    roboAttributeSet = new RoboAttributeSet(asList(new Attribute(TEST_PACKAGE + ":attr/sugarinessPercent", "0x10", TEST_PACKAGE)),
-        resourceLoader);
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/sugarinessPercent", "0x10", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "sugarinessPercent", 0)).isEqualTo(16);
   }
 
   @Test
   public void getAttributeIntValue_shouldReturnStyledValueFromAttribute() throws Exception {
-    roboAttributeSet = new RoboAttributeSet(asList(
+    roboAttributeSet = RoboAttributeSet.create(context,
         new Attribute(TEST_PACKAGE + ":attr/gravity", "center|fill_vertical", TEST_PACKAGE),
         new Attribute("android:attr/orientation", "vertical", TEST_PACKAGE)
-    ), resourceLoader);
+    );
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "gravity", 0)).isEqualTo(0x11 | 0x70);
     assertThat(roboAttributeSet.getAttributeIntValue(ANDROID_NS, "orientation", -1)).isEqualTo(1); // style from LinearLayout
   }
 
   @Test
   public void getAttributeIntValue_shouldNotReturnStyledValueFromAttributeForSuperclass() throws Exception {
-    roboAttributeSet = new RoboAttributeSet(asList(new Attribute(TEST_PACKAGE + ":attr/gravity", "center|fill_vertical", TEST_PACKAGE)),
-        resourceLoader);
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/gravity", "center|fill_vertical", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "gravity", 0)).isEqualTo(Gravity.CENTER | Gravity.FILL_VERTICAL);
   }
 
   @Test
   public void getAttributeIntValue_shouldReturnEnumValuesForEnumAttributes() throws Exception {
-    roboAttributeSet = new RoboAttributeSet(asList(new Attribute(TEST_PACKAGE + ":attr/itemType", "ungulate", TEST_PACKAGE)),
-        resourceLoader);
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/itemType", "ungulate", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "itemType", 0)).isEqualTo(1);
   }
 
   @Test
   public void getAttributeIntValue_whenTypeAllowsIntOrEnum_withInt_shouldReturnInt() throws Exception {
-    roboAttributeSet = new RoboAttributeSet(asList(
+    roboAttributeSet = RoboAttributeSet.create(context,
         new Attribute(TEST_PACKAGE + ":attr/numColumns", "3", TEST_PACKAGE)
-    ), resourceLoader);
+    );
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "numColumns", 0)).isEqualTo(3);
   }
 
   @Test
   public void getAttributeIntValue_whenTypeAllowsIntOrEnum_withEnum_shouldReturnInt() throws Exception {
-    roboAttributeSet = new RoboAttributeSet(asList(
+    roboAttributeSet = RoboAttributeSet.create(context,
         new Attribute(TEST_PACKAGE + ":attr/numColumns", "auto_fit", TEST_PACKAGE)
-    ), resourceLoader);
+    );
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "numColumns", 0)).isEqualTo(-1);
   }
 
   @Test
   public void getAttributeValue_shouldReturnAttributeAssociatedWithResourceId() throws Exception {
-    createTestAttributeSet(new Attribute("ns:attr/textStyle2", "expected value", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("ns:attr/textStyle2", "expected value", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeValue(0)).isEqualTo("expected value");
   }
 
   @Test
   public void getAttributeValue_shouldReturnNullIfNoAttributeSet() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     int nonExistantResource = 12345;
     assertThat(roboAttributeSet.getAttributeValue(nonExistantResource)).isNull();
   }
 
   @Test
   public void getAttributeIntValue_shouldReturnValueFromAttributeWhenNotInAttributeSet() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "sugarinessPercent", 42)).isEqualTo(42);
   }
 
   @Test
   public void getAttributeIntValue_shouldReturnEnumValuesForEnumAttributesWhenNotInAttributeSet() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     assertThat(roboAttributeSet.getAttributeIntValue(TEST_PACKAGE_NS, "itemType", 24)).isEqualTo(24);
   }
 
   @Test
   public void getAttributeFloatValue_shouldGetFloatValuesFromAttributes() throws Exception {
-    createTestAttributeSet(new Attribute(TEST_PACKAGE + ":attr/sugaryScale", "1234.456", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(TEST_PACKAGE + ":attr/sugaryScale", "1234.456", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeFloatValue(TEST_PACKAGE_NS, "sugaryScale", 78.9f)).isEqualTo(1234.456f);
   }
 
   @Test
   public void getAttributeFloatValue_withNamespace_shouldGetFloatValuesFromAttributes() throws Exception {
-    createTestAttributeSet(new Attribute("xxx:attr/sugaryScale", "1234.456", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("xxx:attr/sugaryScale", "1234.456", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeFloatValue(ANDROID_RES_NS_PREFIX + "xxx", "sugaryScale", 78.9f)).isEqualTo(1234.456f);
   }
 
   @Test
   public void getAttributeFloatValue_shouldReturnDefaultFloatValueWhenNotInAttributeSet() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     assertThat(roboAttributeSet.getAttributeFloatValue(TEST_PACKAGE_NS, "sugaryScale", 78.9f)).isEqualTo(78.9f);
   }
 
   @Test
   public void getStyleAttribute_doesNotThrowException() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     roboAttributeSet.getStyleAttribute();
   }
 
   @Test
   public void getStyleAttribute_returnsZeroWhenNoStyle() throws Exception {
-    createTestAttributeSet();
+    roboAttributeSet = RoboAttributeSet.create(context);
     assertThat(roboAttributeSet.getStyleAttribute()).isEqualTo(0);
   }
 
   @Test
   public void getStyleAttribute_returnsCorrectValue() throws Exception {
-    createTestAttributeSet(new Attribute(":attr/style", "@style/FancyStyle", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(":attr/style", "@style/FancyStyle", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getStyleAttribute()).isEqualTo(R.style.FancyStyle);
   }
 
   @Test
   public void getStyleAttribute_doesNotThrowException_whenStyleIsBogus() throws Exception {
-    createTestAttributeSet(new Attribute(":attr/style", "@style/bogus_style", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute(":attr/style", "@style/bogus_style", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getStyleAttribute()).isEqualTo(0);
   }
 
   @Test public void shouldConsiderSameNamedAttrsFromLibrariesEquivalent() throws Exception {
-    createTestAttributeSet(new Attribute("org.robolectric.lib1:attr/offsetX", "1", TEST_PACKAGE));
+    roboAttributeSet = RoboAttributeSet.create(context,
+        new Attribute("org.robolectric.lib1:attr/offsetX", "1", TEST_PACKAGE)
+    );
     assertThat(roboAttributeSet.getAttributeValue(ANDROID_RES_NS_PREFIX + "org.robolectric.lib1", "offsetX")).isEqualTo("1");
     assertThat(roboAttributeSet.getAttributeValue(ANDROID_RES_NS_PREFIX + "org.robolectric.lib2", "offsetX")).isEqualTo("1");
   }
 
   @Test public void getAttributeNameResource() throws Exception {
-    createTestAttributeSet(
+    roboAttributeSet = RoboAttributeSet.create(context,
         new Attribute("org.robolectric.lib1:attr/message", "1", TEST_PACKAGE),
         new Attribute("org.robolectric.lib1:attr/keycode", "1", TEST_PACKAGE)
         );
@@ -294,12 +348,25 @@
     assertThat(roboAttributeSet.getAttributeNameResource(1)).isEqualTo(R.attr.keycode);
   }
 
-  private void createTestAttributeSet(Attribute... attributes) {
-    roboAttributeSet = new RoboAttributeSet(asList(attributes), resourceLoader);
+  @Test
+  public void shouldCreateRoboAttributeSetFromVarargs() {
+    Context context = RuntimeEnvironment.application;
+    ResName resName = new ResName("android", "attr", "orientation");
+    String attrValue = "vertical";
+    String contextPackageName = context.getPackageName();
+
+    ArrayList<Attribute> attributes = new ArrayList<>();
+    attributes.add(new Attribute(resName, attrValue, contextPackageName));
+
+    AttributeSet attributeSet = RoboAttributeSet.create(context, attributes);
+
+    assertThat(attributeSet.getAttributeCount()).isEqualTo(1);
+    assertThat(attributeSet.getAttributeName(0)).isEqualTo(resName.getFullyQualifiedName());
+    assertThat(attributeSet.getAttributeValue(0)).isEqualTo(attrValue);
   }
 
   @Test
-  public void shouldCreateAttributeSet() {
+  public void shouldCreateRoboAttributeSetFromList() {
     Context context = RuntimeEnvironment.application;
     ResName resName = new ResName("android", "attr", "orientation");
     String attrValue = "vertical";
@@ -307,7 +374,7 @@
 
     Attribute attribute = new Attribute(resName, attrValue, contextPackageName);
 
-    RoboAttributeSet attributeSet = RoboAttributeSet.create(context, attribute);
+    AttributeSet attributeSet = RoboAttributeSet.create(context, attribute);
 
     assertThat(attributeSet.getAttributeCount()).isEqualTo(1);
     assertThat(attributeSet.getAttributeName(0)).isEqualTo(resName.getFullyQualifiedName());
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowContextTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowContextTest.java
index 2560b81..38f987f 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowContextTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowContextTest.java
@@ -2,6 +2,7 @@
 
 import android.content.Context;
 import android.content.res.TypedArray;
+import android.util.AttributeSet;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -240,7 +241,7 @@
   @Test
   public void obtainStyledAttributes_shouldExtractAttributesFromAttributeSet() throws Exception {
 
-    RoboAttributeSet roboAttributeSet = RoboAttributeSet.create(context,
+    AttributeSet roboAttributeSet = RoboAttributeSet.create(context,
         new Attribute(TEST_PACKAGE + ":attr/itemType", "ungulate", TEST_PACKAGE),
         new Attribute(TEST_PACKAGE + ":attr/scrollBars", "horizontal|vertical", TEST_PACKAGE),
         new Attribute(TEST_PACKAGE + ":attr/quitKeyCombo", "^q", TEST_PACKAGE),
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowEditTextTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowEditTextTest.java
index d84e1c9..5ebc376 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowEditTextTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowEditTextTest.java
@@ -26,7 +26,7 @@
 
   @Before
   public void setup() {
-    RoboAttributeSet attributeSet = RoboAttributeSet.create(RuntimeEnvironment.application,
+    AttributeSet attributeSet = RoboAttributeSet.create(RuntimeEnvironment.application,
         new Attribute("android:attr/maxLength", "5", R.class.getPackage().getName())
     );
 
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java
index b43926d..60d7b2e 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java
@@ -24,7 +24,7 @@
   private TestPreferenceGroup group;
   private ShadowPreference shadow;
   private Activity activity;
-  private RoboAttributeSet attrs;
+  private AttributeSet attrs;
   private Preference pref1, pref2;
 
   @Before
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowProgressBarTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowProgressBarTest.java
index 3af9855..8a41c27 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowProgressBarTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowProgressBarTest.java
@@ -1,5 +1,6 @@
 package org.robolectric.shadows;
 
+import android.util.AttributeSet;
 import android.widget.ProgressBar;
 
 import org.junit.Before;
@@ -26,7 +27,7 @@
 
   @Before
   public void setUp() {
-    RoboAttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
+    AttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
         new Attribute(new ResName(TestUtil.SYSTEM_PACKAGE, "attr", "max"), "100", TestUtil.TEST_PACKAGE),
         new Attribute(new ResName(TestUtil.SYSTEM_PACKAGE, "attr", "indeterminate"), "false", TestUtil.TEST_PACKAGE),
         new Attribute(new ResName(TestUtil.SYSTEM_PACKAGE, "attr", "indeterminateOnly"), "false", TestUtil.TEST_PACKAGE)
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java
index b8fdfeb..fbcf4b9 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java
@@ -10,6 +10,7 @@
 import android.graphics.drawable.Drawable;
 import android.os.Build;
 import android.os.Bundle;
+import android.util.AttributeSet;
 import android.view.ContextMenu;
 import android.view.HapticFeedbackConstants;
 import android.view.MotionEvent;
@@ -341,7 +342,7 @@
 
   @Test
   public void shouldAddOnClickListenerFromAttribute() throws Exception {
-    RoboAttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
+    AttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
         new Attribute("android:attr/onClick", "clickMe", R.class.getPackage().getName())
     );
 
@@ -353,7 +354,7 @@
   public void shouldCallOnClickWithAttribute() throws Exception {
     MyActivity myActivity = buildActivity(MyActivity.class).create().get();
 
-    RoboAttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
+    AttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
         new Attribute("android:attr/onClick", "clickMe", R.class.getPackage().getName())
     );
 
@@ -366,7 +367,7 @@
   public void shouldThrowExceptionWithBadMethodName() throws Exception {
     MyActivity myActivity = buildActivity(MyActivity.class).create().get();
 
-    RoboAttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
+    AttributeSet attrs = RoboAttributeSet.create(RuntimeEnvironment.application,
         new Attribute("android:onClick", "clickYou", R.class.getPackage().getName())
     );