Implemented ShadowFilterIntent copy constructor.
Closes #1300.
diff --git a/src/main/java/org/robolectric/shadows/ShadowIntentFilter.java b/src/main/java/org/robolectric/shadows/ShadowIntentFilter.java
index c11f526..0e82ceb 100644
--- a/src/main/java/org/robolectric/shadows/ShadowIntentFilter.java
+++ b/src/main/java/org/robolectric/shadows/ShadowIntentFilter.java
@@ -2,6 +2,7 @@
import android.content.IntentFilter;
import android.net.Uri;
+import org.robolectric.Robolectric;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@@ -32,6 +33,7 @@
List<String> types = new ArrayList<String>();
List<IntentFilter.AuthorityEntry> authoritites = new ArrayList<IntentFilter.AuthorityEntry>();
List<String> categories = new ArrayList<String>();
+ int priority;
public void __constructor__(String action) {
actions.add(action);
@@ -41,6 +43,26 @@
actions.add(action);
}
+ public void __constructor__(IntentFilter filter) {
+ ShadowIntentFilter shadow = Robolectric.shadowOf_(filter);
+ actions = new ArrayList<String>(shadow.actions);
+ schemes = new ArrayList<String>(shadow.schemes);
+ types = new ArrayList<String>(shadow.types);
+ authoritites = new ArrayList<IntentFilter.AuthorityEntry>(shadow.authoritites);
+ categories = new ArrayList<String>(shadow.categories);
+ priority = shadow.priority;
+ }
+
+ @Implementation
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ @Implementation
+ public int getPriority() {
+ return priority;
+ }
+
@Implementation
public void addAction(String action) {
actions.add(action);
diff --git a/src/test/java/org/robolectric/shadows/IntentFilterTest.java b/src/test/java/org/robolectric/shadows/IntentFilterTest.java
index 97e0081..9d8690e 100644
--- a/src/test/java/org/robolectric/shadows/IntentFilterTest.java
+++ b/src/test/java/org/robolectric/shadows/IntentFilterTest.java
@@ -1,5 +1,6 @@
package org.robolectric.shadows;
+import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import org.junit.Test;
@@ -11,6 +12,21 @@
@RunWith(TestRunners.WithDefaults.class)
public class IntentFilterTest {
@Test
+ public void copyConstructorTest() throws Exception {
+ String action = "test";
+ IntentFilter intentFilter = new IntentFilter(action);
+ IntentFilter copy = new IntentFilter(intentFilter);
+ assertThat(copy.hasAction("test"));
+ }
+
+ @Test
+ public void setsPriority() throws Exception {
+ IntentFilter filter = new IntentFilter();
+ filter.setPriority(123);
+ assertThat(filter.getPriority()).isEqualTo(123);
+ }
+
+ @Test
public void addDataScheme_shouldAddTheDataScheme() throws Exception {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addDataScheme("http");