conflict_resolution
stringlengths 27
16k
|
---|
<<<<<<<
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.Set;
=======
import nl.basjes.parse.core.exceptions.DisectionFailure;
import static nl.basjes.parse.Utils.resilientUrlDecode;
>>>>>>>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nl.basjes.parse.core.exceptions.DisectionFailure;
import static nl.basjes.parse.Utils.resilientUrlDecode;
import java.util.HashSet;
import java.util.Set;
<<<<<<<
String name = value.substring(0, equalPos).toLowerCase();
if (requestedParameters.contains(name)) {
=======
String name = value.substring(0, equalPos).toLowerCase();
try {
>>>>>>>
String name = value.substring(0, equalPos).toLowerCase();
if (requestedParameters.contains(name)) {
try {
<<<<<<<
Utils.resilientUrlDecode(value.substring(equalPos + 1, value.length())));
=======
resilientUrlDecode(value.substring(equalPos + 1, value.length())));
} catch (IllegalArgumentException e) {
// This usually means that there was invalid encoding in the line
throw new DisectionFailure(e.getMessage());
>>>>>>>
resilientUrlDecode(value.substring(equalPos + 1, value.length())));
} catch (IllegalArgumentException e) {
// This usually means that there was invalid encoding in the line
throw new DisectionFailure(e.getMessage());
} |
<<<<<<<
public DirectoryObjectReferenceRequestBuilder(final String requestUrl, final IBaseClient client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, DirectoryObjectReferenceRequest.class);
=======
public DirectoryObjectReferenceRequestBuilder(@Nonnull final String requestUrl, @Nonnull final IBaseClient client, @Nullable final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
super(requestUrl, client, requestOptions);
}
/**
* Creates the request
*
* @param requestOptions the options for this request
* @return The DirectoryObjectReferenceRequest instance
*/
@Nonnull
public DirectoryObjectReferenceRequest buildRequest(@Nullable final com.microsoft.graph.options.Option... requestOptions) {
return buildRequest(getOptions(requestOptions));
}
/**
* Creates the request with specific requestOptions instead of the existing requestOptions
*
* @param requestOptions the options for this request
* @return the DirectoryObjectReferenceRequest instance
*/
@Nonnull
public DirectoryObjectReferenceRequest buildRequest(@Nonnull final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
return new DirectoryObjectReferenceRequest(getRequestUrl(), getClient(), requestOptions);
>>>>>>>
public DirectoryObjectReferenceRequestBuilder(@Nonnull final String requestUrl, @Nonnull final IBaseClient client, @Nullable final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, DirectoryObjectReferenceRequest.class); |
<<<<<<<
/**
* Creates a new Segment
* @param newSegment the Segment to create
* @return the newly created object
*/
public Segment post(final Segment newSegment) throws ClientException {
=======
@Nonnull
public Segment post(@Nonnull final Segment newSegment) throws ClientException {
>>>>>>>
/**
* Creates a new Segment
* @param newSegment the Segment to create
* @return the newly created object
*/
@Nonnull
public Segment post(@Nonnull final Segment newSegment) throws ClientException {
<<<<<<<
public SegmentCollectionRequest expand(final String value) {
addExpandOption(value);
return this;
=======
@Nonnull
public SegmentCollectionRequest expand(@Nonnull final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$expand", value));
return (SegmentCollectionRequest)this;
>>>>>>>
@Nonnull
public SegmentCollectionRequest expand(@Nonnull final String value) {
addExpandOption(value);
return this;
<<<<<<<
public SegmentCollectionRequest filter(final String value) {
addFilterOption(value);
return this;
=======
@Nonnull
public SegmentCollectionRequest filter(@Nonnull final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$filter", value));
return (SegmentCollectionRequest)this;
>>>>>>>
@Nonnull
public SegmentCollectionRequest filter(@Nonnull final String value) {
addFilterOption(value);
return this;
<<<<<<<
public SegmentCollectionRequest orderBy(final String value) {
addOrderByOption(value);
return this;
=======
@Nonnull
public SegmentCollectionRequest orderBy(@Nonnull final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$orderby", value));
return (SegmentCollectionRequest)this;
>>>>>>>
@Nonnull
public SegmentCollectionRequest orderBy(@Nonnull final String value) {
addOrderByOption(value);
return this;
<<<<<<<
public SegmentCollectionRequest select(final String value) {
addSelectOption(value);
return this;
=======
@Nonnull
public SegmentCollectionRequest select(@Nonnull final String value) {
addQueryOption(new com.microsoft.graph.options.QueryOption("$select", value));
return (SegmentCollectionRequest)this;
>>>>>>>
@Nonnull
public SegmentCollectionRequest select(@Nonnull final String value) {
addSelectOption(value);
return this;
<<<<<<<
public SegmentCollectionRequest skipToken(final String skipToken) {
addSkipTokenOption(skipToken);
return this;
=======
@Nonnull
public SegmentCollectionRequest skipToken(@Nonnull final String skipToken) {
addQueryOption(new QueryOption("$skiptoken", skipToken));
return (SegmentCollectionRequest)this;
}
@Nonnull
public SegmentCollectionPage buildFromResponse(@Nonnull final SegmentCollectionResponse response) {
final SegmentCollectionRequestBuilder builder;
if (response.nextLink != null) {
builder = new SegmentCollectionRequestBuilder(response.nextLink, getBaseRequest().getClient(), /* options */ null);
} else {
builder = null;
}
final SegmentCollectionPage page = new SegmentCollectionPage(response, builder);
page.setRawObject(response.getSerializer(), response.getRawObject());
return page;
>>>>>>>
@Nonnull
public SegmentCollectionRequest skipToken(@Nonnull final String skipToken) {
addSkipTokenOption(skipToken);
return this; |
<<<<<<<
public EndpointRequest select(final String value) {
addSelectOption(value);
return this;
=======
@Nonnull
public EndpointRequest select(@Nonnull final String value) {
getQueryOptions().add(new com.microsoft.graph.options.QueryOption("$select", value));
return (EndpointRequest)this;
>>>>>>>
@Nonnull
public EndpointRequest select(@Nonnull final String value) {
addSelectOption(value);
return this;
<<<<<<<
public EndpointRequest expand(final String value) {
addExpandOption(value);
return this;
=======
@Nonnull
public EndpointRequest expand(@Nonnull final String value) {
getQueryOptions().add(new com.microsoft.graph.options.QueryOption("$expand", value));
return (EndpointRequest)this;
>>>>>>>
@Nonnull
public EndpointRequest expand(@Nonnull final String value) {
addExpandOption(value);
return this; |
<<<<<<<
public OptionRequest select(final String value) {
addSelectOption(value);
return this;
=======
@Nonnull
public OptionRequest select(@Nonnull final String value) {
getQueryOptions().add(new com.microsoft.graph.options.QueryOption("$select", value));
return (OptionRequest)this;
>>>>>>>
@Nonnull
public OptionRequest select(@Nonnull final String value) {
addSelectOption(value);
return this;
<<<<<<<
public OptionRequest expand(final String value) {
addExpandOption(value);
return this;
=======
@Nonnull
public OptionRequest expand(@Nonnull final String value) {
getQueryOptions().add(new com.microsoft.graph.options.QueryOption("$expand", value));
return (OptionRequest)this;
>>>>>>>
@Nonnull
public OptionRequest expand(@Nonnull final String value) {
addExpandOption(value);
return this; |
<<<<<<<
public EntityType3CollectionWithReferencesRequestBuilder(final String requestUrl, final IBaseClient client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, EntityType3ReferenceRequestBuilder.class, EntityType3CollectionReferenceRequest.class, EntityType3CollectionReferenceRequestBuilder.class);
=======
public EntityType3CollectionWithReferencesRequestBuilder(@Nonnull final String requestUrl, @Nonnull final IBaseClient client, @Nullable final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
super(requestUrl, client, requestOptions);
}
/**
* Creates the request
*
* @param requestOptions the options for this request
* @return the IUserRequest instance
*/
@Nonnull
public EntityType3CollectionWithReferencesRequest buildRequest(@Nullable final com.microsoft.graph.options.Option... requestOptions) {
return buildRequest(getOptions(requestOptions));
}
/**
* Creates the request
*
* @param requestOptions the options for this request
* @return the IUserRequest instance
*/
@Nonnull
public EntityType3CollectionWithReferencesRequest buildRequest(@Nonnull final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
return new EntityType3CollectionWithReferencesRequest(getRequestUrl(), getClient(), requestOptions);
}
@Nonnull
public EntityType3WithReferenceRequestBuilder byId(@Nonnull final String id) {
return new EntityType3WithReferenceRequestBuilder(getRequestUrlWithAdditionalSegment(id), getClient(), getOptions());
}
@Nonnull
public EntityType3CollectionReferenceRequestBuilder references(){
return new EntityType3CollectionReferenceRequestBuilder(getRequestUrl() + "/$ref", getClient(), getOptions());
>>>>>>>
public EntityType3CollectionWithReferencesRequestBuilder(@Nonnull final String requestUrl, @Nonnull final IBaseClient client, @Nullable final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, EntityType3ReferenceRequestBuilder.class, EntityType3CollectionReferenceRequest.class, EntityType3CollectionReferenceRequestBuilder.class); |
<<<<<<<
public static final String TRANSACTION_PROCESSOR_ACTIONS_EMPTY_ERROR_MSG = "Action list can't be empty!";
public static final String TRANSACTION_PROCESSOR_RPC_GET_INFO = "Error happened on calling GetInfo RPC.";
public static final String TRANSACTION_PROCESSOR_PREPARE_RPC_GET_BLOCK = "Error happened on calling GetBlock RPC.";
public static final String TRANSACTION_PROCESSOR_HEAD_BLOCK_TIME_PARSE_ERROR = "Failed to parse head block time";
public static final String TRANSACTION_PROCESSOR_HEAD_BLOCK_TIME_PARSE_NULL_ERROR = "NullPointerException happened on parsing head block time";
public static final String TRANSACTION_PROCESSOR_PREPARE_CLONE_ERROR = "Error happened on cloning transaction.";
public static final String TRANSACTION_PROCESSOR_PREPARE_CLONE_CLASS_NOT_FOUND = "Transaction class was not found";
public static final String TRANSACTION_PROCESSOR_TRANSACTION_HAS_TO_BE_INITIALIZED = "Transaction must be initialized before this method could be called! call prepare for initialize Transaction";
public static final String TRANSACTION_PROCESSOR_GET_ABI_ERROR = "Error happened on getting abi for contract [%s]";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_ACTION_WORKED_BUT_EMPTY_RESULT = "Serialization of action worked fine but got back empty result!";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_TRANSACTION_WORKED_BUT_EMPTY_RESULT = "Serialization of transaction worked fine but got back empty result!";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_ACTION_ERROR = "Error happened on serializing action [%s]";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_TRANSACTION_ERROR = "Error happened on serializing transaction";
public static final String TRANSACTION_PROCESSOR_GET_AVAILABLE_KEY_ERROR = "Error happened on getAvailableKeys from SignatureProvider!";
public static final String TRANSACTION_PROCESSOR_GET_AVAILABLE_KEY_EMPTY = "Signature provider return no available key";
public static final String TRANSACTION_PROCESSOR_RPC_GET_REQUIRED_KEYS = "Error happened on calling getRequiredKeys RPC call.";
public static final String GET_REQUIRED_KEY_RPC_EMPTY_RESULT = "GetRequiredKeys RPC returned no required keys";
public static final String TRANSACTION_PROCESSOR_SIGN_TRANSACTION_ERROR = "Error happened on calling sign transaction of Signature provider";
public static final String TRANSACTION_IS_NOT_ALLOWED_TOBE_MODIFIED = "The transaction is not allowed to be modified but was modified by signature provider!";
public static final String TRANSACTION_PROCESSOR_GET_SIGN_DESERIALIZE_TRANS_ERROR = "Error happened on calling deserializeTransaction to refresh transaction object with new values";
public static final String TRANSACTION_PROCESSOR_RPC_PUSH_TRANSACTION = "Error happened on calling pushTransaction RPC call";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_ERROR = "Error happened on calling serializeTransaction";
public static final String TRANSACTION_PROCESSOR_SIGN_CREATE_SIGN_REQUEST_ERROR = "Error happened on creating signature request for Signature Provider to sign!";
public static final String TRANSACTION_PROCESSOR_BROADCAST_TRANS_ERROR = "Error happened on pushing transaction to chain!";
public static final String TRANSACTION_PROCESSOR_REQUIRED_KEY_NOT_SUBSET = "Required keys from back end are not available in available keys from Signature Provider.";
public static final String TRANSACTION_PROCESSOR_PREPARE_CANT_INIT_TRANS = "Can't initialize/clone transaction!";
public static final String TRANSACTION_PROCESSOR_BROADCAST_SERIALIZED_TRANSACTION_EMPTY = "Serialized Transaction is empty or has not been populated. Make sure to call prepare then sign before calling broadcast";
=======
public static final String PUBLIC_KEY_DECOMPRESSION_ERROR = "Problem decompressing public key!";
public static final String PUBLIC_KEY_COMPRESSION_ERROR = "Problem compressing public key";
// ABIProviderImpl Errors
public static final String NO_RESPONSE_RETRIEVING_ABI = "No response retrieving ABI.";
public static final String MISSING_ABI_FROM_RESPONSE = "Missing ABI from GetRawAbiResponse.";
public static final String CALCULATED_HASH_NOT_EQUAL_RETURNED = "Calculated ABI hash does not match returned hash.";
public static final String REQUESTED_ACCCOUNT_NOT_EQUAL_RETURNED = "Requested account name does not match returned account name.";
public static final String NO_ABI_FOUND = "No ABI found for requested account name.";
public static final String ERROR_RETRIEVING_ABI = "Error retrieving ABI from the chain.";
>>>>>>>
public static final String TRANSACTION_PROCESSOR_ACTIONS_EMPTY_ERROR_MSG = "Action list can't be empty!";
public static final String TRANSACTION_PROCESSOR_RPC_GET_INFO = "Error happened on calling GetInfo RPC.";
public static final String TRANSACTION_PROCESSOR_PREPARE_RPC_GET_BLOCK = "Error happened on calling GetBlock RPC.";
public static final String TRANSACTION_PROCESSOR_HEAD_BLOCK_TIME_PARSE_ERROR = "Failed to parse head block time";
public static final String TRANSACTION_PROCESSOR_HEAD_BLOCK_TIME_PARSE_NULL_ERROR = "NullPointerException happened on parsing head block time";
public static final String TRANSACTION_PROCESSOR_PREPARE_CLONE_ERROR = "Error happened on cloning transaction.";
public static final String TRANSACTION_PROCESSOR_PREPARE_CLONE_CLASS_NOT_FOUND = "Transaction class was not found";
public static final String TRANSACTION_PROCESSOR_TRANSACTION_HAS_TO_BE_INITIALIZED = "Transaction must be initialized before this method could be called! call prepare for initialize Transaction";
public static final String TRANSACTION_PROCESSOR_GET_ABI_ERROR = "Error happened on getting abi for contract [%s]";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_ACTION_WORKED_BUT_EMPTY_RESULT = "Serialization of action worked fine but got back empty result!";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_TRANSACTION_WORKED_BUT_EMPTY_RESULT = "Serialization of transaction worked fine but got back empty result!";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_ACTION_ERROR = "Error happened on serializing action [%s]";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_TRANSACTION_ERROR = "Error happened on serializing transaction";
public static final String TRANSACTION_PROCESSOR_GET_AVAILABLE_KEY_ERROR = "Error happened on getAvailableKeys from SignatureProvider!";
public static final String TRANSACTION_PROCESSOR_GET_AVAILABLE_KEY_EMPTY = "Signature provider return no available key";
public static final String TRANSACTION_PROCESSOR_RPC_GET_REQUIRED_KEYS = "Error happened on calling getRequiredKeys RPC call.";
public static final String GET_REQUIRED_KEY_RPC_EMPTY_RESULT = "GetRequiredKeys RPC returned no required keys";
public static final String TRANSACTION_PROCESSOR_SIGN_TRANSACTION_ERROR = "Error happened on calling sign transaction of Signature provider";
public static final String TRANSACTION_IS_NOT_ALLOWED_TOBE_MODIFIED = "The transaction is not allowed to be modified but was modified by signature provider!";
public static final String TRANSACTION_PROCESSOR_GET_SIGN_DESERIALIZE_TRANS_ERROR = "Error happened on calling deserializeTransaction to refresh transaction object with new values";
public static final String TRANSACTION_PROCESSOR_RPC_PUSH_TRANSACTION = "Error happened on calling pushTransaction RPC call";
public static final String TRANSACTION_PROCESSOR_SERIALIZE_ERROR = "Error happened on calling serializeTransaction";
public static final String TRANSACTION_PROCESSOR_SIGN_CREATE_SIGN_REQUEST_ERROR = "Error happened on creating signature request for Signature Provider to sign!";
public static final String TRANSACTION_PROCESSOR_BROADCAST_TRANS_ERROR = "Error happened on pushing transaction to chain!";
public static final String TRANSACTION_PROCESSOR_REQUIRED_KEY_NOT_SUBSET = "Required keys from back end are not available in available keys from Signature Provider.";
public static final String TRANSACTION_PROCESSOR_PREPARE_CANT_INIT_TRANS = "Can't initialize/clone transaction!";
public static final String TRANSACTION_PROCESSOR_BROADCAST_SERIALIZED_TRANSACTION_EMPTY = "Serialized Transaction is empty or has not been populated. Make sure to call prepare then sign before calling broadcast";
public static final String PUBLIC_KEY_DECOMPRESSION_ERROR = "Problem decompressing public key!";
public static final String PUBLIC_KEY_COMPRESSION_ERROR = "Problem compressing public key";
// ABIProviderImpl Errors
public static final String NO_RESPONSE_RETRIEVING_ABI = "No response retrieving ABI.";
public static final String MISSING_ABI_FROM_RESPONSE = "Missing ABI from GetRawAbiResponse.";
public static final String CALCULATED_HASH_NOT_EQUAL_RETURNED = "Calculated ABI hash does not match returned hash.";
public static final String REQUESTED_ACCCOUNT_NOT_EQUAL_RETURNED = "Requested account name does not match returned account name.";
public static final String NO_ABI_FOUND = "No ABI found for requested account name.";
public static final String ERROR_RETRIEVING_ABI = "Error retrieving ABI from the chain."; |
<<<<<<<
=======
import android.util.Xml;
>>>>>>>
import android.util.Xml;
<<<<<<<
=======
public void getText_withHtml() throws Exception {
assertThat(resources.getText(R.string.some_html, "value").toString()).isEqualTo("Hello, world");
}
@Test
public void getDimension() throws Exception {
DisplayMetrics dm = RuntimeEnvironment.application.getResources().getDisplayMetrics();
assertThat(dm.density).isEqualTo(1.0f);
assertThat(resources.getDimension(R.dimen.test_dip_dimen)).isEqualTo(20f);
assertThat(resources.getDimension(R.dimen.test_dp_dimen)).isEqualTo(8f);
assertThat(resources.getDimension(R.dimen.test_in_dimen)).isEqualTo(99f * 160);
assertThat(resources.getDimension(R.dimen.test_mm_dimen)).isEqualTo(((float) (42f / 25.4 * 160)));
assertThat(resources.getDimension(R.dimen.test_px_dimen)).isEqualTo(15f);
assertThat(resources.getDimension(R.dimen.test_pt_dimen)).isEqualTo(12f * 160 / 72);
assertThat(resources.getDimension(R.dimen.test_sp_dimen)).isEqualTo(5);
}
@Test
public void getDimensionPixelSize() throws Exception {
assertThat(resources.getDimensionPixelSize(R.dimen.test_dip_dimen)).isEqualTo(20);
assertThat(resources.getDimensionPixelSize(R.dimen.test_dp_dimen)).isEqualTo(8);
assertThat(resources.getDimensionPixelSize(R.dimen.test_in_dimen)).isEqualTo(99 * 160);
assertThat(resources.getDimensionPixelSize(R.dimen.test_mm_dimen)).isEqualTo(265);
assertThat(resources.getDimensionPixelSize(R.dimen.test_px_dimen)).isEqualTo(15);
assertThat(resources.getDimensionPixelSize(R.dimen.test_pt_dimen)).isEqualTo(27);
assertThat(resources.getDimensionPixelSize(R.dimen.test_sp_dimen)).isEqualTo(5);
}
@Test
public void getDimensionPixelOffset() throws Exception {
assertThat(resources.getDimensionPixelOffset(R.dimen.test_dip_dimen)).isEqualTo(20);
assertThat(resources.getDimensionPixelOffset(R.dimen.test_dp_dimen)).isEqualTo(8);
assertThat(resources.getDimensionPixelOffset(R.dimen.test_in_dimen)).isEqualTo(99 * 160);
assertThat(resources.getDimensionPixelOffset(R.dimen.test_mm_dimen)).isEqualTo(264);
assertThat(resources.getDimensionPixelOffset(R.dimen.test_px_dimen)).isEqualTo(15);
assertThat(resources.getDimensionPixelOffset(R.dimen.test_pt_dimen)).isEqualTo(26);
assertThat(resources.getDimensionPixelOffset(R.dimen.test_sp_dimen)).isEqualTo(5);
}
@Test
@Config(qualifiers = "en")
>>>>>>>
@Config(qualifiers = "en") |
<<<<<<<
=======
/**
* Non-Android accessor that sets the value to be returned by {@link #getDimension(int)}
*
* @param id ID to set the dimension for
* @param value value to be returned
*/
public void setDimension(int id, int value) {
resourceLoader.dimensions.put(id, value);
}
public ResourceExtractor getResourceExtractor() {
return resourceLoader.getResourceExtractor();
}
>>>>>>> |
<<<<<<<
@Test
public void applyStyleForced() {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.MyBlackTheme, true);
TypedArray arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColorHint });
TypedValue backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
arr.recycle();
assertThat(backgroundColor.resourceId).isEqualTo(android.R.color.black);
theme.applyStyle(R.style.MyBlueTheme, true);
arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColor, android.R.attr.textColorHint});
backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
TypedValue textColor = new TypedValue();
arr.getValue(1, textColor);
TypedValue textColorHint = new TypedValue();
arr.getValue(2, textColorHint);
arr.recycle();
assertThat(backgroundColor.resourceId).isEqualTo(R.color.blue);
assertThat(textColor.resourceId).isEqualTo(R.color.white);
assertThat(textColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
}
@Test
public void applyStyleNotForced() {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.MyBlackTheme, true);
TypedArray arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColorHint });
TypedValue backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
TypedValue textColorHint = new TypedValue();
arr.getValue(1, textColorHint);
arr.recycle();
assertThat(backgroundColor.resourceId).isEqualTo(android.R.color.black);
assertThat(textColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
theme.applyStyle(R.style.MyBlueTheme, false);
arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColor, android.R.attr.textColorHint});
backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
TypedValue textColor = new TypedValue();
arr.getValue(1, textColor);
textColorHint = new TypedValue();
arr.getValue(2, textColorHint);
arr.recycle();
assertThat(textColor.resourceId).isEqualTo(R.color.white);
assertThat(textColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
assertThat(backgroundColor.resourceId).isEqualTo(android.R.color.black);
}
=======
@Test
public void subClassInitializedOK() {
SubClassResources subClassResources = new SubClassResources(Robolectric.getShadowApplication().getResources());
assertThat(subClassResources.openRawResource(R.raw.raw_resource)).isNotNull();
}
private static class SubClassResources extends Resources {
public SubClassResources(Resources res) {
super(res.getAssets(), res.getDisplayMetrics(), res.getConfiguration());
}
}
>>>>>>>
@Test
public void subClassInitializedOK() {
SubClassResources subClassResources = new SubClassResources(Robolectric.getShadowApplication().getResources());
assertThat(subClassResources.openRawResource(R.raw.raw_resource)).isNotNull();
}
private static class SubClassResources extends Resources {
public SubClassResources(Resources res) {
super(res.getAssets(), res.getDisplayMetrics(), res.getConfiguration());
}
}
@Test
public void applyStyleForced() {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.MyBlackTheme, true);
TypedArray arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColorHint });
TypedValue backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
arr.recycle();
assertThat(backgroundColor.resourceId).isEqualTo(android.R.color.black);
theme.applyStyle(R.style.MyBlueTheme, true);
arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColor, android.R.attr.textColorHint});
backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
TypedValue textColor = new TypedValue();
arr.getValue(1, textColor);
TypedValue textColorHint = new TypedValue();
arr.getValue(2, textColorHint);
arr.recycle();
assertThat(backgroundColor.resourceId).isEqualTo(R.color.blue);
assertThat(textColor.resourceId).isEqualTo(R.color.white);
assertThat(textColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
}
@Test
public void applyStyleNotForced() {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.MyBlackTheme, true);
TypedArray arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColorHint });
TypedValue backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
TypedValue textColorHint = new TypedValue();
arr.getValue(1, textColorHint);
arr.recycle();
assertThat(backgroundColor.resourceId).isEqualTo(android.R.color.black);
assertThat(textColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
theme.applyStyle(R.style.MyBlueTheme, false);
arr = theme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground, android.R.attr.textColor, android.R.attr.textColorHint});
backgroundColor = new TypedValue();
arr.getValue(0, backgroundColor);
TypedValue textColor = new TypedValue();
arr.getValue(1, textColor);
textColorHint = new TypedValue();
arr.getValue(2, textColorHint);
arr.recycle();
assertThat(textColor.resourceId).isEqualTo(R.color.white);
assertThat(textColorHint.resourceId).isEqualTo(android.R.color.darker_gray);
assertThat(backgroundColor.resourceId).isEqualTo(android.R.color.black);
} |
<<<<<<<
=======
import android.widget.Spinner;
import com.xtremelabs.robolectric.Robolectric;
>>>>>>>
import android.widget.Spinner;
<<<<<<<
=======
Robolectric.bindDefaultShadowClasses();
Context context = new Activity();
>>>>>>>
context = new Activity(); |
<<<<<<<
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Looper;
import android.preference.DialogPreference;
import android.preference.Preference;
import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
=======
import android.os.*;
import android.preference.*;
import android.telephony.TelephonyManager;
>>>>>>>
import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
<<<<<<<
ShadowCursorAdapter.class,
ShadowDateFormat.class,
=======
ShadowCursorAdapter.class,
>>>>>>>
ShadowCursorAdapter.class,
ShadowDateFormat.class,
<<<<<<<
ShadowPair.class,
=======
ShadowParcel.class,
>>>>>>>
ShadowPair.class,
ShadowParcel.class,
<<<<<<<
ShadowRatingBar.class,
=======
ShadowProgressDialog.class,
>>>>>>>
ShadowProgressDialog.class,
ShadowRatingBar.class,
<<<<<<<
ShadowTabHost.class,
ShadowTabSpec.class,
ShadowTelephonyManager.class,
=======
ShadowTelephonyManager.class,
>>>>>>>
ShadowTabHost.class,
ShadowTabSpec.class,
ShadowTelephonyManager.class,
<<<<<<<
public static ShadowActivityGroup shadowOf(ActivityGroup instance) {
return (ShadowActivityGroup) shadowOf_(instance);
}
=======
public static ShadowListPreference shadowOf(ListPreference instance) {
return (ShadowListPreference) shadowOf_(instance);
}
>>>>>>>
public static ShadowActivityGroup shadowOf(ActivityGroup instance) {
return (ShadowActivityGroup) shadowOf_(instance);
}
public static ShadowListPreference shadowOf(ListPreference instance) {
return (ShadowListPreference) shadowOf_(instance);
} |
<<<<<<<
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
=======
import android.graphics.*;
import com.xtremelabs.robolectric.util.Implementation;
import com.xtremelabs.robolectric.util.Implements;
>>>>>>>
import android.graphics.*;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements; |
<<<<<<<
import android.app.ResourcesManager;
=======
import android.content.BroadcastReceiver;
import android.content.ComponentName;
>>>>>>>
import android.content.BroadcastReceiver;
import android.content.ComponentName;
<<<<<<<
import android.content.res.CompatibilityInfo;
=======
import android.content.pm.PackageParser;
import android.content.res.AssetManager;
>>>>>>>
import android.content.pm.PackageParser;
import android.content.res.AssetManager;
<<<<<<<
import android.os.Build.VERSION_CODES;
=======
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
>>>>>>>
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
<<<<<<<
import org.robolectric.shadow.api.Shadow;
=======
import org.robolectric.shadows.ClassNameResolver;
import org.robolectric.shadows.LegacyManifestParser;
import org.robolectric.shadows.ShadowActivityThread;
import org.robolectric.shadows.ShadowContextImpl;
import org.robolectric.shadows.ShadowLog;
>>>>>>>
import org.robolectric.shadows.ClassNameResolver;
import org.robolectric.shadows.LegacyManifestParser;
import org.robolectric.shadows.ShadowActivityThread;
import org.robolectric.shadows.ShadowContextImpl;
import org.robolectric.shadows.ShadowLog;
<<<<<<<
import org.robolectric.shadows.ShadowResourcesManager;
=======
import org.robolectric.shadows.ShadowPackageParser;
import org.robolectric.util.PerfStatsCollector;
>>>>>>>
import org.robolectric.shadows.ShadowPackageParser;
import org.robolectric.util.PerfStatsCollector;
<<<<<<<
public void resetStaticState(Config config) {
RuntimeEnvironment.setMainThread(Thread.currentThread());
Robolectric.reset();
if (!loggingInitialized) {
shadowsAdapter.setupLogging();
loggingInitialized = true;
}
}
@Override
public void setUpApplicationState(Method method, TestLifecycle testLifecycle,
AndroidManifest appManifest,
DependencyResolver jarResolver, Config config, ResourceTable compileTimeResourceTable,
ResourceTable appResourceTable,
ResourceTable systemResourceTable, FsFile compileTimeSystemResourcesFile) {
=======
public void setUpApplicationState(
Method method,
AndroidManifest appManifest,
Config config,
ResourceTable compileTimeResourceTable,
ResourceTable appResourceTable,
ResourceTable systemResourceTable) {
>>>>>>>
public void setUpApplicationState(Method method, AndroidManifest appManifest,
DependencyResolver jarResolver,Config config, ResourceTable compileTimeResourceTable,
ResourceTable appResourceTable,
ResourceTable systemResourceTable, FsFile compileTimeSystemResourcesFile) {
<<<<<<<
// JDK has a default locale of en_US. A previous test may have changed the default, so reset it
// here
Locale.setDefault(Locale.US);
Resources systemResources = Resources.getSystem();
=======
>>>>>>>
<<<<<<<
appResources.updateConfiguration(configuration, displayMetrics);
=======
appResources.updateConfiguration(configuration, displayMetrics);
populateAssetPaths(appResources.getAssets(), appManifest);
initInstrumentation(activityThread, applicationInfo);
>>>>>>>
appResources.updateConfiguration(configuration, displayMetrics);
populateAssetPaths(appResources.getAssets(), appManifest);
initInstrumentation(activityThread, applicationInfo); |
<<<<<<<
import android.view.View;
import android.view.View.MeasureSpec;
=======
>>>>>>>
import android.view.View;
<<<<<<<
import com.xtremelabs.robolectric.internal.Implementation;
=======
>>>>>>>
import com.xtremelabs.robolectric.internal.Implementation;
<<<<<<<
@Implementation
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
layout(right, top, right + width, top + height);
}
@Implementation
@Override
public ViewGroup.LayoutParams getLayoutParams() {
return layoutParams;
}
@Override
protected void setChildLayoutParams(View child) {
child.setLayoutParams(new FrameLayout.LayoutParams(0, 0));
}
=======
>>>>>>>
@Implementation
@Override
public ViewGroup.LayoutParams getLayoutParams() {
return layoutParams;
}
@Override
protected void setChildLayoutParams(View child) {
child.setLayoutParams(new FrameLayout.LayoutParams(0, 0));
} |
<<<<<<<
=======
import android.view.View;
import android.view.ViewGroup;
>>>>>>>
import android.view.View;
<<<<<<<
=======
@Override
protected void setChildLayoutParams(View child) {
child.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
}
>>>>>>>
@Override
protected void setChildLayoutParams(View child) {
child.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
} |
<<<<<<<
private int phoneType = TelephonyManager.PHONE_TYPE_GSM;
=======
private String simCountryIso;
>>>>>>>
private int phoneType = TelephonyManager.PHONE_TYPE_GSM;
private String simCountryIso; |
<<<<<<<
private PreferenceLoader preferenceLoader;
private final StringResourceLoader stringResourceLoader;
private final PluralResourceLoader pluralResourceLoader;
private final StringArrayResourceLoader stringArrayResourceLoader;
private final AttrResourceLoader attrResourceLoader;
private final ColorResourceLoader colorResourceLoader;
private final DrawableResourceLoader drawableResourceLoader;
private final RawResourceLoader rawResourceLoader;
=======
private StringResourceLoader stringResourceLoader;
private StringArrayResourceLoader stringArrayResourceLoader;
private ColorResourceLoader colorResourceLoader;
private final List<RawResourceLoader> rawResourceLoaders = new ArrayList<RawResourceLoader>();
>>>>>>>
private PreferenceLoader preferenceLoader;
private final StringResourceLoader stringResourceLoader;
private final PluralResourceLoader pluralResourceLoader;
private final StringArrayResourceLoader stringArrayResourceLoader;
private final AttrResourceLoader attrResourceLoader;
private final ColorResourceLoader colorResourceLoader;
private final DrawableResourceLoader drawableResourceLoader;
private final List<RawResourceLoader> rawResourceLoaders = new ArrayList<RawResourceLoader>();
<<<<<<<
stringResourceLoader = new StringResourceLoader(resourceExtractor);
pluralResourceLoader = new PluralResourceLoader(resourceExtractor, stringResourceLoader);
stringArrayResourceLoader = new StringArrayResourceLoader(resourceExtractor, stringResourceLoader);
colorResourceLoader = new ColorResourceLoader(resourceExtractor);
attrResourceLoader = new AttrResourceLoader(resourceExtractor);
drawableResourceLoader = new DrawableResourceLoader(resourceExtractor, resourceDir);
rawResourceLoader = new RawResourceLoader(resourceExtractor, resourceDir);
this.resourceDir = resourceDir;
=======
this.resourcePath = Collections.unmodifiableList(resourcePath);
>>>>>>>
stringResourceLoader = new StringResourceLoader(resourceExtractor);
pluralResourceLoader = new PluralResourceLoader(resourceExtractor, stringResourceLoader);
stringArrayResourceLoader = new StringArrayResourceLoader(resourceExtractor, stringResourceLoader);
colorResourceLoader = new ColorResourceLoader(resourceExtractor);
attrResourceLoader = new AttrResourceLoader(resourceExtractor);
drawableResourceLoader = new DrawableResourceLoader(resourceExtractor);
this.resourcePath = Collections.unmodifiableList(resourcePath);
<<<<<<<
private void loadPluralsResources(File localResourceDir, File systemValueResourceDir) throws Exception {
DocumentLoader stringResourceDocumentLoader = new DocumentLoader(this.pluralResourceLoader);
loadValueResourcesFromDirs(stringResourceDocumentLoader, localResourceDir, systemValueResourceDir);
}
private void loadValueResources(File localResourceDir, File systemValueResourceDir) throws Exception {
=======
private void loadValueResources(File resourceDir, StringArrayResourceLoader stringArrayResourceLoader, ColorResourceLoader colorResourceLoader, AttrResourceLoader attrResourceLoader, boolean system) throws Exception {
>>>>>>>
private void loadPluralsResources(File resourceDir, boolean system) throws Exception {
DocumentLoader stringResourceDocumentLoader = new DocumentLoader(this.pluralResourceLoader);
loadValueResourcesFromDirs(stringResourceDocumentLoader, resourceDir, system);
}
private void loadValueResources(File resourceDir, StringArrayResourceLoader stringArrayResourceLoader, ColorResourceLoader colorResourceLoader, AttrResourceLoader attrResourceLoader, boolean system) throws Exception {
<<<<<<<
loadLayoutResourceXmlSubDirs(viewDocumentLoader, xmlResourceDir, false);
loadLayoutResourceXmlSubDirs(viewDocumentLoader, systemResourceDir, true);
=======
loadLayoutResourceXmlSubDirs(viewDocumentLoader, resourceDir);
>>>>>>>
loadLayoutResourceXmlSubDirs(viewDocumentLoader, resourceDir, system);
<<<<<<<
private void loadDrawableResourceXmlDirs(DocumentLoader drawableResourceLoader, File xmlResourceDir) throws Exception {
if (xmlResourceDir != null) {
drawableResourceLoader.loadResourceXmlDirs(xmlResourceDir.listFiles(DRAWABLE_DIR_FILE_FILTER));
}
}
private void loadValueResourcesFromDirs(DocumentLoader documentLoader, File localValueResourceDir, File systemValueResourceDir) throws Exception {
loadValueResourcesFromDir(documentLoader, localValueResourceDir);
loadSystemResourceXmlDir(documentLoader, systemValueResourceDir);
=======
private void loadValueResourcesFromDirs(DocumentLoader documentLoader, File resourceDir, boolean system) throws Exception {
if (system) {
loadSystemResourceXmlDir(documentLoader, resourceDir);
} else {
loadValueResourcesFromDir(documentLoader, resourceDir);
}
>>>>>>>
private void loadDrawableResourceXmlDirs(DocumentLoader drawableResourceLoader, File xmlResourceDir) throws Exception {
if (xmlResourceDir != null) {
drawableResourceLoader.loadResourceXmlDirs(xmlResourceDir.listFiles(DRAWABLE_DIR_FILE_FILTER));
}
}
private void loadValueResourcesFromDirs(DocumentLoader documentLoader, File resourceDir, boolean system) throws Exception {
if (system) {
loadSystemResourceXmlDir(documentLoader, resourceDir);
} else {
loadValueResourcesFromDir(documentLoader, resourceDir);
}
<<<<<<<
pluralResourceLoader = null;
viewLoader = null;
stringArrayResourceLoader = null;
attrResourceLoader = null;
colorResourceLoader = null;
drawableResourceLoader = null;
rawResourceLoader = null;
=======
>>>>>>>
pluralResourceLoader = null;
viewLoader = null;
stringArrayResourceLoader = null;
attrResourceLoader = null;
colorResourceLoader = null;
drawableResourceLoader = null; |
<<<<<<<
sdkProvider.getSdk(16),
mock(ConfigCollection.class),
=======
sdkCollection.getSdk(16),
mock(Config.class),
>>>>>>>
sdkCollection.getSdk(16),
mock(ConfigCollection.class),
<<<<<<<
sdkProvider.getSdk(17),
mock(ConfigCollection.class),
=======
sdkCollection.getSdk(17),
mock(Config.class),
>>>>>>>
sdkCollection.getSdk(17),
mock(ConfigCollection.class),
<<<<<<<
sdkProvider.getSdk(16),
mock(ConfigCollection.class),
=======
sdkCollection.getSdk(16),
mock(Config.class),
>>>>>>>
sdkCollection.getSdk(16),
mock(ConfigCollection.class),
<<<<<<<
sdkProvider.getSdk(16),
mock(ConfigCollection.class),
=======
sdkCollection.getSdk(16),
mock(Config.class),
>>>>>>>
sdkCollection.getSdk(16),
mock(ConfigCollection.class), |
<<<<<<<
ShadowIntent fakeIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertEquals("bar", fakeIntent.extras.get("foo"));
=======
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.proxyFor(intent);
assertEquals("bar", shadowIntent.extras.get("foo"));
>>>>>>>
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertEquals("bar", shadowIntent.extras.get("foo"));
<<<<<<<
ShadowIntent fakeIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertEquals(2, fakeIntent.extras.get("foo"));
assertEquals(2, fakeIntent.getIntExtra("foo", -1));
=======
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.proxyFor(intent);
assertEquals(2, shadowIntent.extras.get("foo"));
assertEquals(2, shadowIntent.getIntExtra("foo", -1));
>>>>>>>
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertEquals(2, shadowIntent.extras.get("foo"));
assertEquals(2, shadowIntent.getIntExtra("foo", -1));
<<<<<<<
ShadowIntent fakeIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertEquals(serializable, fakeIntent.extras.get("foo"));
assertNotSame(serializable, fakeIntent.extras.get("foo"));
assertEquals(serializable, fakeIntent.getSerializableExtra("foo"));
assertNotSame(serializable, fakeIntent.getSerializableExtra("foo"));
=======
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.proxyFor(intent);
assertEquals(serializable, shadowIntent.extras.get("foo"));
assertNotSame(serializable, shadowIntent.extras.get("foo"));
assertEquals(serializable, shadowIntent.getSerializableExtra("foo"));
assertNotSame(serializable, shadowIntent.getSerializableExtra("foo"));
>>>>>>>
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertEquals(serializable, shadowIntent.extras.get("foo"));
assertNotSame(serializable, shadowIntent.extras.get("foo"));
assertEquals(serializable, shadowIntent.getSerializableExtra("foo"));
assertNotSame(serializable, shadowIntent.getSerializableExtra("foo"));
<<<<<<<
ShadowIntent fakeIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertSame(parcelable, fakeIntent.extras.get("foo"));
assertSame(parcelable, fakeIntent.getParcelableExtra("foo"));
=======
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.proxyFor(intent);
assertSame(parcelable, shadowIntent.extras.get("foo"));
assertSame(parcelable, shadowIntent.getParcelableExtra("foo"));
>>>>>>>
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertSame(parcelable, shadowIntent.extras.get("foo"));
assertSame(parcelable, shadowIntent.getParcelableExtra("foo"));
<<<<<<<
ShadowIntent fakeIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertSame(uri, fakeIntent.data);
=======
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.proxyFor(intent);
assertSame(uri, shadowIntent.data);
>>>>>>>
ShadowIntent shadowIntent = (ShadowIntent) DogfoodRobolectricTestRunner.shadowFor(intent);
assertSame(uri, shadowIntent.data); |
<<<<<<<
public static final class id {
public static final int time = nextId++;
public static final int title = nextId++;
public static final int subtitle = nextId++;
public static final int snippet_text = nextId++;
public static final int include_id = nextId++;
public static final int inner_text = nextId++;
public static final int map_view = nextId++;
public static final int true_checkbox = nextId++;
public static final int false_checkbox = nextId++;
public static final int default_checkbox = nextId++;
public static final int image = nextId++;
public static final int edit_text = nextId++;
public static final int edit_text2 = nextId++;
public static final int outer_merge = nextId++;
public static final int web_view = nextId++;
public static final int test_menu_1 = nextId++;
public static final int test_menu_2 = nextId++;
}
=======
public static final class id {
public static final int time = nextId++;
public static final int title = nextId++;
public static final int subtitle = nextId++;
public static final int snippet_text = nextId++;
public static final int include_id = nextId++;
public static final int inner_text = nextId++;
public static final int map_view = nextId++;
public static final int true_checkbox = nextId++;
public static final int false_checkbox = nextId++;
public static final int default_checkbox = nextId++;
public static final int image = nextId++;
public static final int edit_text = nextId++;
public static final int edit_text2 = nextId++;
public static final int outer_merge = nextId++;
public static final int web_view = nextId++;
public static final int textStyle = nextId++;
public static final int textStyle2 = nextId++;
public static final int textStyle3 = nextId++;
}
>>>>>>>
public static final class id {
public static final int time = nextId++;
public static final int title = nextId++;
public static final int subtitle = nextId++;
public static final int snippet_text = nextId++;
public static final int include_id = nextId++;
public static final int inner_text = nextId++;
public static final int map_view = nextId++;
public static final int true_checkbox = nextId++;
public static final int false_checkbox = nextId++;
public static final int default_checkbox = nextId++;
public static final int image = nextId++;
public static final int edit_text = nextId++;
public static final int edit_text2 = nextId++;
public static final int outer_merge = nextId++;
public static final int web_view = nextId++;
public static final int textStyle = nextId++;
public static final int textStyle2 = nextId++;
public static final int textStyle3 = nextId++;
public static final int test_menu_1 = nextId++;
public static final int test_menu_2 = nextId++;
} |
<<<<<<<
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;
=======
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.util.Implementation;
import com.xtremelabs.robolectric.util.Implements;
import com.xtremelabs.robolectric.util.RealObject;
>>>>>>>
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject; |
<<<<<<<
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
=======
import android.widget.TextView;
>>>>>>>
import android.widget.LinearLayout;
import android.widget.TextView;
<<<<<<<
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.TestRunners;
=======
import com.xtremelabs.robolectric.RobolectricConfig;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
>>>>>>>
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.TestRunners;
<<<<<<<
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import static com.xtremelabs.robolectric.Robolectric.DEFAULT_SDK_VERSION;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.*;
=======
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import static com.xtremelabs.robolectric.Robolectric.application;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.*;
>>>>>>>
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import static com.xtremelabs.robolectric.Robolectric.DEFAULT_SDK_VERSION;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.*;
<<<<<<<
@Before
public void setUp() throws Exception {
context = new Application();
ShadowApplication.bind(context, new ResourceLoader(DEFAULT_SDK_VERSION, R.class, (File) null, null));
=======
@Before
public void setUp() throws Exception {
Application context = new Application();
ShadowApplication.bind(context, new ResourceLoader(RobolectricConfig.DEFAULT_SDK, R.class, (File) null, null));
>>>>>>>
@Before
public void setUp() throws Exception {
context = new Application();
ShadowApplication.bind(context, new ResourceLoader(DEFAULT_SDK_VERSION, R.class, (File) null, null));
<<<<<<<
assertThat(root.getLayoutAnimationListener(), nullValue());
AnimationListener animationListener = new AnimationListener() {
@Override
public void onAnimationEnd(Animation a) { }
@Override
public void onAnimationRepeat(Animation a) { }
@Override
public void onAnimationStart(Animation a) { }
};
root.setLayoutAnimationListener(animationListener);
assertThat(root.getLayoutAnimationListener(), sameInstance(animationListener));
=======
assertThat(root.getLayoutAnimationListener(), nullValue());
root.setLayoutAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation a) {
}
@Override
public void onAnimationRepeat(Animation a) {
}
@Override
public void onAnimationStart(Animation a) {
}
});
assertThat(root.getLayoutAnimationListener(), notNullValue());
>>>>>>>
assertThat(root.getLayoutAnimationListener(), nullValue());
AnimationListener animationListener = new AnimationListener() {
@Override
public void onAnimationEnd(Animation a) { }
@Override
public void onAnimationRepeat(Animation a) { }
@Override
public void onAnimationStart(Animation a) { }
};
root.setLayoutAnimationListener(animationListener);
assertThat(root.getLayoutAnimationListener(), sameInstance(animationListener));
<<<<<<<
root.removeAllViews();
child1.setTag("tag1");
child2.setTag("tag2");
child3.setTag("tag3");
root.addView(child1);
root.addView(child2);
root.addView(child3, 1);
assertThat(root.findViewWithTag("tag1"), sameInstance(child1));
assertThat(root.findViewWithTag("tag2"), sameInstance((View) child2));
assertThat((ViewGroup) root.findViewWithTag("tag3"), sameInstance(child3));
=======
root.removeAllViews();
String tag1 = "tag1";
String tag2 = "tag2";
String tag3 = "tag3";
child1.setTag(tag1);
child2.setTag(tag2);
child3.setTag(tag3);
root.addView(child1);
root.addView(child2);
root.addView(child3, 1);
assertThat(root.findViewWithTag("tag1"), sameInstance(child1));
assertThat(root.findViewWithTag("tag2"), sameInstance((View) child2));
assertThat((ViewGroup) root.findViewWithTag("tag3"), sameInstance(child3));
>>>>>>>
root.removeAllViews();
child1.setTag("tag1");
child2.setTag("tag2");
child3.setTag("tag3");
root.addView(child1);
root.addView(child2);
root.addView(child3, 1);
assertThat(root.findViewWithTag("tag1"), sameInstance(child1));
assertThat(root.findViewWithTag("tag2"), sameInstance((View) child2));
assertThat((ViewGroup) root.findViewWithTag("tag3"), sameInstance(child3));
<<<<<<<
root.removeAllViews();
child1.setTag("tag1");
child2.setTag("tag2");
child3.setTag("tag3");
root.addView(child1);
root.addView(child2);
root.addView(child3, 1);
assertThat(root.findViewWithTag("tag21"), equalTo(null));
assertThat((ViewGroup) root.findViewWithTag("tag23"), equalTo(null));
=======
root.removeAllViews();
String tag1 = "tag1";
String tag2 = "tag2";
String tag3 = "tag3";
child1.setTag(tag1);
child2.setTag(tag2);
child3.setTag(tag3);
root.addView(child1);
root.addView(child2);
root.addView(child3, 1);
assertThat(root.findViewWithTag("tag21"), equalTo(null));
assertThat((ViewGroup) root.findViewWithTag("tag23"), equalTo(null));
>>>>>>>
root.removeAllViews();
child1.setTag("tag1");
child2.setTag("tag2");
child3.setTag("tag3");
root.addView(child1);
root.addView(child2);
root.addView(child3, 1);
assertThat(root.findViewWithTag("tag21"), equalTo(null));
assertThat((ViewGroup) root.findViewWithTag("tag23"), equalTo(null));
<<<<<<<
child3b.setVisibility(View.GONE);
TextView textView = new TextView(context);
textView.setText("Here's some text!");
textView.setVisibility(View.INVISIBLE);
child3.addView(textView);
=======
child3b.setVisibility(View.GONE);
TextView textView = new TextView(application);
textView.setText("Here's some text!");
textView.setVisibility(View.INVISIBLE);
child3.addView(textView);
>>>>>>>
child3b.setVisibility(View.GONE);
TextView textView = new TextView(context);
textView.setText("Here's some text!");
textView.setVisibility(View.INVISIBLE);
child3.addView(textView);
<<<<<<<
@Test
public void addViewWithLayoutParams_shouldStoreLayoutParams() throws Exception {
FrameLayout.LayoutParams layoutParams1 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ImageView child1 = new ImageView(Robolectric.application);
ImageView child2 = new ImageView(Robolectric.application);
root.addView(child1, layoutParams1);
root.addView(child2, 1, layoutParams2);
assertSame(layoutParams1, child1.getLayoutParams());
assertSame(layoutParams2, child2.getLayoutParams());
}
=======
@Test
public void getChildAt_shouldReturnNullForInvalidIndices() {
assertThat(root.getChildCount(), equalTo(3));
assertThat(root.getChildAt(13), nullValue());
assertThat(root.getChildAt(3), nullValue());
assertThat(root.getChildAt(-1), nullValue());
}
@Test
public void layoutParams_shouldBeViewGroupLayoutParams() {
assertThat(child1.getLayoutParams(), instanceOf(FrameLayout.LayoutParams.class));
assertThat(child1.getLayoutParams(), instanceOf(ViewGroup.LayoutParams.class));
}
>>>>>>>
@Test
public void addViewWithLayoutParams_shouldStoreLayoutParams() throws Exception {
FrameLayout.LayoutParams layoutParams1 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
View child1 = new View(Robolectric.application);
View child2 = new View(Robolectric.application);
root.addView(child1, layoutParams1);
root.addView(child2, 1, layoutParams2);
assertSame(layoutParams1, child1.getLayoutParams());
assertSame(layoutParams2, child2.getLayoutParams());
}
@Test
public void getChildAt_shouldReturnNullForInvalidIndices() {
assertThat(root.getChildCount(), equalTo(3));
assertThat(root.getChildAt(13), nullValue());
assertThat(root.getChildAt(3), nullValue());
assertThat(root.getChildAt(-1), nullValue());
}
@Test
public void layoutParams_shouldBeViewGroupLayoutParams() {
assertThat(child1.getLayoutParams(), instanceOf(FrameLayout.LayoutParams.class));
assertThat(child1.getLayoutParams(), instanceOf(ViewGroup.LayoutParams.class));
} |
<<<<<<<
@Test
public void testShouldBeAbleToTurnOffAutomaticRowUpdates() throws Exception {
try {
TranscriptAdapter adapter1 = new TranscriptAdapter();
assertThat(adapter1.getCount(), equalTo(1));
listView.setAdapter(adapter1);
transcript.assertEventsSoFar("called getView");
transcript.clear();
adapter1.notifyDataSetChanged();
transcript.assertEventsSoFar("called getView");
transcript.clear();
ShadowAdapterView.automaticallyUpdateRowViews(false);
TranscriptAdapter adapter2 = new TranscriptAdapter();
assertThat(adapter2.getCount(), equalTo(1));
listView.setAdapter(adapter2);
adapter2.notifyDataSetChanged();
transcript.assertNoEventsSoFar();
} finally {
ShadowAdapterView.automaticallyUpdateRowViews(true);
}
}
=======
@Test(expected = UnsupportedOperationException.class)
public void removeAllViews_shouldThrowAnException() throws Exception {
listView.removeAllViews();
}
@Test(expected = UnsupportedOperationException.class)
public void removeView_shouldThrowAnException() throws Exception {
listView.removeView(new View(null));
}
@Test(expected = UnsupportedOperationException.class)
public void removeViewAt_shouldThrowAnException() throws Exception {
listView.removeViewAt(0);
}
@Test
public void getPositionForView_shouldReturnThePositionInTheListForTheView() throws Exception {
prepareWithListAdapter();
View childViewOfListItem = ((ViewGroup) listView.getChildAt(1)).getChildAt(0);
assertThat(listView.getPositionForView(childViewOfListItem), equalTo(1));
}
@Test
public void getPositionForView_shouldReturnInvalidPostionForViewThatIsNotFound() throws Exception {
prepareWithListAdapter();
assertThat(listView.getPositionForView(new View(null)), equalTo(AdapterView.INVALID_POSITION));
}
>>>>>>>
@Test
public void testShouldBeAbleToTurnOffAutomaticRowUpdates() throws Exception {
try {
TranscriptAdapter adapter1 = new TranscriptAdapter();
assertThat(adapter1.getCount(), equalTo(1));
listView.setAdapter(adapter1);
transcript.assertEventsSoFar("called getView");
transcript.clear();
adapter1.notifyDataSetChanged();
transcript.assertEventsSoFar("called getView");
transcript.clear();
ShadowAdapterView.automaticallyUpdateRowViews(false);
TranscriptAdapter adapter2 = new TranscriptAdapter();
assertThat(adapter2.getCount(), equalTo(1));
listView.setAdapter(adapter2);
adapter2.notifyDataSetChanged();
transcript.assertNoEventsSoFar();
} finally {
ShadowAdapterView.automaticallyUpdateRowViews(true);
}
}
@Test(expected = UnsupportedOperationException.class)
public void removeAllViews_shouldThrowAnException() throws Exception {
listView.removeAllViews();
}
@Test(expected = UnsupportedOperationException.class)
public void removeView_shouldThrowAnException() throws Exception {
listView.removeView(new View(null));
}
@Test(expected = UnsupportedOperationException.class)
public void removeViewAt_shouldThrowAnException() throws Exception {
listView.removeViewAt(0);
}
@Test
public void getPositionForView_shouldReturnThePositionInTheListForTheView() throws Exception {
prepareWithListAdapter();
View childViewOfListItem = ((ViewGroup) listView.getChildAt(1)).getChildAt(0);
assertThat(listView.getPositionForView(childViewOfListItem), equalTo(1));
}
@Test
public void getPositionForView_shouldReturnInvalidPostionForViewThatIsNotFound() throws Exception {
prepareWithListAdapter();
assertThat(listView.getPositionForView(new View(null)), equalTo(AdapterView.INVALID_POSITION));
} |
<<<<<<<
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder()), usesSdk))
.containsExactly(sdkProvider.getSdk(22));
=======
assertThat(sdkPicker.selectSdks(new Config.Builder().build(), usesSdk))
.containsExactly(sdkCollection.getSdk(22));
>>>>>>>
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder()), usesSdk))
.containsExactly(sdkCollection.getSdk(22));
<<<<<<<
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkProvider.getSdk(19), sdkProvider.getSdk(21),
sdkProvider.getSdk(22), sdkProvider.getSdk(23));
=======
assertThat(sdkPicker.selectSdks(new Config.Builder().setSdk(Config.ALL_SDKS).build(), usesSdk))
.containsExactly(sdkCollection.getSdk(19), sdkCollection.getSdk(21),
sdkCollection.getSdk(22), sdkCollection.getSdk(23));
>>>>>>>
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkCollection.getSdk(19), sdkCollection.getSdk(21),
sdkCollection.getSdk(22), sdkCollection.getSdk(23));
<<<<<<<
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkProvider.getSdk(16), sdkProvider.getSdk(17),
sdkProvider.getSdk(18), sdkProvider.getSdk(19),
sdkProvider.getSdk(21), sdkProvider.getSdk(22));
=======
assertThat(sdkPicker.selectSdks(new Config.Builder().setSdk(Config.ALL_SDKS).build(), usesSdk))
.containsExactly(sdkCollection.getSdk(16), sdkCollection.getSdk(17),
sdkCollection.getSdk(18), sdkCollection.getSdk(19),
sdkCollection.getSdk(21), sdkCollection.getSdk(22));
>>>>>>>
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkCollection.getSdk(16), sdkCollection.getSdk(17),
sdkCollection.getSdk(18), sdkCollection.getSdk(19),
sdkCollection.getSdk(21), sdkCollection.getSdk(22));
<<<<<<<
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkProvider.getSdk(19), sdkProvider.getSdk(21),
sdkProvider.getSdk(22), sdkProvider.getSdk(23));
=======
assertThat(sdkPicker.selectSdks(new Config.Builder().setSdk(Config.ALL_SDKS).build(), usesSdk))
.containsExactly(sdkCollection.getSdk(19), sdkCollection.getSdk(21),
sdkCollection.getSdk(22), sdkCollection.getSdk(23));
>>>>>>>
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkCollection.getSdk(19), sdkCollection.getSdk(21),
sdkCollection.getSdk(22), sdkCollection.getSdk(23));
<<<<<<<
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder()), usesSdk))
.containsExactly(sdkProvider.getSdk(16));
=======
assertThat(sdkPicker.selectSdks(new Config.Builder().build(), usesSdk))
.containsExactly(sdkCollection.getSdk(16));
>>>>>>>
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder()), usesSdk))
.containsExactly(sdkCollection.getSdk(16));
<<<<<<<
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setMinSdk(21)), usesSdk))
.containsExactly(sdkProvider.getSdk(21), sdkProvider.getSdk(22),
sdkProvider.getSdk(23));
=======
assertThat(sdkPicker.selectSdks(new Config.Builder().setMinSdk(21).build(), usesSdk))
.containsExactly(sdkCollection.getSdk(21), sdkCollection.getSdk(22),
sdkCollection.getSdk(23));
>>>>>>>
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setMinSdk(21)), usesSdk))
.containsExactly(sdkCollection.getSdk(21), sdkCollection.getSdk(22),
sdkCollection.getSdk(23));
<<<<<<<
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setMaxSdk(21)), usesSdk))
.containsExactly(sdkProvider.getSdk(19), sdkProvider.getSdk(21));
=======
assertThat(sdkPicker.selectSdks(new Config.Builder().setMaxSdk(21).build(), usesSdk))
.containsExactly(sdkCollection.getSdk(19), sdkCollection.getSdk(21));
>>>>>>>
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setMaxSdk(21)), usesSdk))
.containsExactly(sdkCollection.getSdk(19), sdkCollection.getSdk(21));
<<<<<<<
sdkPicker = new DefaultSdkPicker(map(sdkInts), map(17, 18));
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkProvider.getSdk(17), sdkProvider.getSdk(18));
=======
sdkPicker = new DefaultSdkPicker(sdkCollection, "17,18");
assertThat(sdkPicker.selectSdks(new Config.Builder().setSdk(Config.ALL_SDKS).build(), usesSdk))
.containsExactly(sdkCollection.getSdk(17), sdkCollection.getSdk(18));
>>>>>>>
sdkPicker = new DefaultSdkPicker(sdkCollection, "17,18");
assertThat(sdkPicker.selectSdks(buildConfig(new Config.Builder().setSdk(Config.ALL_SDKS)), usesSdk))
.containsExactly(sdkCollection.getSdk(17), sdkCollection.getSdk(18)); |
<<<<<<<
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
=======
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
>>>>>>>
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true; |
<<<<<<<
private HashMap<String, String> attributes;
private ResourceExtractor resourceExtractor;
@Before
public void setUp() throws Exception {
attributes = new HashMap<String, String>();
resourceExtractor = new ResourceExtractor();
resourceExtractor.addLocalRClass(R.class);
resourceExtractor.addSystemRClass(android.R.class);
}
@Test
public void getSystemAttributeResourceValue_shouldReturnTheResourceValue() throws Exception {
attributes.put("android:id", "@android:id/text1");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("android", "id", 0), equalTo(android.R.id.text1));
}
@Test
public void getAttributeResourceValue_shouldReturnTheResourceValue() throws Exception {
attributes.put("message", "@string/howdy");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", 0), equalTo(R.string.howdy));
}
@Test
public void getAttributeResourceValue_withNamespace_shouldReturnTheResourceValue() throws Exception {
attributes.put("xxx:message", "@string/howdy");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", 0), equalTo(R.string.howdy));
}
@Test
public void getAttributeResourceValue_shouldReturnDefaultValueWhenNotInAttributeSet() throws Exception {
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", -1), equalTo(-1));
}
@Test
public void getAttributeBooleanValue_shouldGetBooleanValuesFromAttributes() throws Exception {
attributes.put("isSugary", "true");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", false), equalTo(true));
}
@Test
public void getAttributeBooleanValue_withNamespace_shouldGetBooleanValuesFromAttributes() throws Exception {
attributes.put("xxx:isSugary", "true");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", false), equalTo(true));
}
@Test
public void getAttributeBooleanValue_shouldReturnDefaultBooleanValueWhenNotInAttributeSet() throws Exception {
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", true), equalTo(true));
}
@Test
public void getAttributeValue_shouldReturnValueFromAttribute() throws Exception {
attributes.put("isSugary", "oh heck yeah");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeValue("some namespace", "isSugary"), equalTo("oh heck yeah"));
}
@Test
public void getAttributeIntValue_shouldReturnValueFromAttribute() throws Exception {
attributes.put("sugarinessPercent", "100");
AttrResourceLoader resourceLoader = new AttrResourceLoader(resourceExtractor);
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, resourceLoader, View.class);
assertThat(testAttributeSet.getAttributeIntValue("some namespace", "sugarinessPercent", 0), equalTo(100));
}
@Test
public void getAttributeIntValue_shouldReturnEnumValuesForEnumAttributes() throws Exception {
attributes.put("itemType", "string");
AttrResourceLoader attrResourceLoader = new AttrResourceLoader(resourceExtractor);
new DocumentLoader(attrResourceLoader).loadLocalResourceXmlDir(resourceFile("res", "values"));
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, attrResourceLoader, CustomView.class);
assertThat(testAttributeSet.getAttributeIntValue("some namespace", "itemType", 0), equalTo(1));
}
=======
private HashMap<String, String> attributes;
private ResourceExtractor resourceExtractor;
@Before public void setUp() throws Exception {
attributes = new HashMap<String, String>();
resourceExtractor = new ResourceExtractor();
resourceExtractor.addLocalRClass(R.class);
}
@Test
public void getAttributeResourceValue_shouldReturnTheResourceValue() throws Exception {
attributes.put("message", "@string/howdy");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", 0), equalTo(R.string.howdy));
}
@Test
public void getAttributeResourceValue_withNamespace_shouldReturnTheResourceValue() throws Exception {
attributes.put("xxx:message", "@string/howdy");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", 0), equalTo(R.string.howdy));
}
@Test
public void getAttributeResourceValue_shouldReturnDefaultValueWhenNotInAttributeSet() throws Exception {
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", -1), equalTo(-1));
}
@Test
public void getAttributeBooleanValue_shouldGetBooleanValuesFromAttributes() throws Exception {
attributes.put("isSugary", "true");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", false), equalTo(true));
}
@Test
public void getAttributeBooleanValue_withNamespace_shouldGetBooleanValuesFromAttributes() throws Exception {
attributes.put("xxx:isSugary", "true");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", false), equalTo(true));
}
@Test
public void getAttributeBooleanValue_shouldReturnDefaultBooleanValueWhenNotInAttributeSet() throws Exception {
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", true), equalTo(true));
}
@Test
public void getAttributeValue_shouldReturnValueFromAttribute() throws Exception {
attributes.put("isSugary", "oh heck yeah");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeValue("some namespace", "isSugary"), equalTo("oh heck yeah"));
}
@Test
public void getAttributeIntValue_shouldReturnValueFromAttribute() throws Exception {
attributes.put("sugarinessPercent", "100");
AttrResourceLoader resourceLoader = new AttrResourceLoader(resourceExtractor);
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, resourceLoader, View.class);
assertThat(testAttributeSet.getAttributeIntValue("some namespace", "sugarinessPercent", 0), equalTo(100));
}
@Test
public void getAttributeIntValue_shouldReturnEnumValuesForEnumAttributes() throws Exception {
attributes.put("itemType", "string");
AttrResourceLoader attrResourceLoader = new AttrResourceLoader(resourceExtractor);
new DocumentLoader(attrResourceLoader).loadResourceXmlDir(resourceFile("res", "values"));
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, attrResourceLoader, CustomView.class);
assertThat(testAttributeSet.getAttributeIntValue("some namespace", "itemType", 0), equalTo(1));
}
>>>>>>>
private HashMap<String, String> attributes;
private ResourceExtractor resourceExtractor;
@Before
public void setUp() throws Exception {
attributes = new HashMap<String, String>();
resourceExtractor = new ResourceExtractor();
resourceExtractor.addLocalRClass(R.class);
resourceExtractor.addSystemRClass(android.R.class);
}
@Test
public void getSystemAttributeResourceValue_shouldReturnTheResourceValue() throws Exception {
attributes.put("android:id", "@android:id/text1");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("android", "id", 0), equalTo(android.R.id.text1));
}
@Test
public void getAttributeResourceValue_shouldReturnTheResourceValue() throws Exception {
attributes.put("message", "@string/howdy");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", 0), equalTo(R.string.howdy));
}
@Test
public void getAttributeResourceValue_withNamespace_shouldReturnTheResourceValue() throws Exception {
attributes.put("xxx:message", "@string/howdy");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", 0), equalTo(R.string.howdy));
}
@Test
public void getAttributeResourceValue_shouldReturnDefaultValueWhenNotInAttributeSet() throws Exception {
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, resourceExtractor, null, null);
assertThat(testAttributeSet.getAttributeResourceValue("some namespace", "message", -1), equalTo(-1));
}
@Test
public void getAttributeBooleanValue_shouldGetBooleanValuesFromAttributes() throws Exception {
attributes.put("isSugary", "true");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", false), equalTo(true));
}
@Test
public void getAttributeBooleanValue_withNamespace_shouldGetBooleanValuesFromAttributes() throws Exception {
attributes.put("xxx:isSugary", "true");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", false), equalTo(true));
}
@Test
public void getAttributeBooleanValue_shouldReturnDefaultBooleanValueWhenNotInAttributeSet() throws Exception {
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeBooleanValue("some namespace", "isSugary", true), equalTo(true));
}
@Test
public void getAttributeValue_shouldReturnValueFromAttribute() throws Exception {
attributes.put("isSugary", "oh heck yeah");
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, null, null);
assertThat(testAttributeSet.getAttributeValue("some namespace", "isSugary"), equalTo("oh heck yeah"));
}
@Test
public void getAttributeIntValue_shouldReturnValueFromAttribute() throws Exception {
attributes.put("sugarinessPercent", "100");
AttrResourceLoader resourceLoader = new AttrResourceLoader(resourceExtractor);
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, resourceLoader, View.class);
assertThat(testAttributeSet.getAttributeIntValue("some namespace", "sugarinessPercent", 0), equalTo(100));
}
@Test
public void getAttributeIntValue_shouldReturnEnumValuesForEnumAttributes() throws Exception {
attributes.put("itemType", "string");
AttrResourceLoader attrResourceLoader = new AttrResourceLoader(resourceExtractor);
new DocumentLoader(attrResourceLoader).loadResourceXmlDir(resourceFile("res", "values"));
TestAttributeSet testAttributeSet = new TestAttributeSet(attributes, null, attrResourceLoader, CustomView.class);
assertThat(testAttributeSet.getAttributeIntValue("some namespace", "itemType", 0), equalTo(1));
} |
<<<<<<<
import android.content.res.AssetManager;
=======
>>>>>>>
import android.content.res.AssetManager;
<<<<<<<
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
=======
>>>>>>>
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;
<<<<<<<
import java.io.InputStream;
import java.util.Locale;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
=======
import com.xtremelabs.robolectric.util.Implementation;
import com.xtremelabs.robolectric.util.Implements;
import com.xtremelabs.robolectric.util.RealObject;
import java.io.InputStream;
import java.util.Locale;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
>>>>>>>
import java.io.InputStream;
import java.util.Locale;
import static com.xtremelabs.robolectric.Robolectric.shadowOf; |
<<<<<<<
=======
import com.google.common.collect.ImmutableList;
>>>>>>>
import com.google.common.collect.ImmutableList;
<<<<<<<
@RunWith(TestRunners.MultiApiSelfTest.class)
=======
@RunWith(RobolectricTestRunner.class)
>>>>>>>
@RunWith(RobolectricTestRunner.class)
<<<<<<<
@Config(minSdk = Build.VERSION_CODES.O)
public void deleteNotificationChannel() {
final String channelId = "channelId";
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.createNotificationChannel(new NotificationChannel(channelId, "name", 1));
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.deleteNotificationChannel(channelId);
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isTrue();
assertThat(notificationManager.getNotificationChannel(channelId)).isNull();
// Per documentation, recreating a deleted channel should have the same settings as the old
// deleted channel.
notificationManager.createNotificationChannel(
new NotificationChannel(channelId, "otherName", 2));
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
NotificationChannel channel = notificationManager.getNotificationChannel(channelId);
assertThat(channel.getName()).isEqualTo("name");
assertThat(channel.getImportance()).isEqualTo(1);
}
@Test
@Config(minSdk = Build.VERSION_CODES.N)
public void areNotificationsEnabled() {
shadowOf(notificationManager).setNotificationsEnabled(true);
assertThat(notificationManager.areNotificationsEnabled()).isTrue();
shadowOf(notificationManager).setNotificationsEnabled(false);
assertThat(notificationManager.areNotificationsEnabled()).isFalse();
}
@Test
=======
@Config(minSdk = Build.VERSION_CODES.O)
public void createNotificationChannels() {
NotificationChannel channel1 = new NotificationChannel("id", "name", 1);
NotificationChannel channel2 = new NotificationChannel("id2", "name2", 1);
notificationManager.createNotificationChannels(ImmutableList.of(channel1, channel2));
assertThat(shadowOf(notificationManager).getNotificationChannels()).hasSize(2);
NotificationChannel channel =
(NotificationChannel) shadowOf(notificationManager).getNotificationChannel("id");
assertThat(channel.getName()).isEqualTo("name");
assertThat(channel.getImportance()).isEqualTo(1);
channel = (NotificationChannel) shadowOf(notificationManager).getNotificationChannel("id2");
assertThat(channel.getName()).isEqualTo("name2");
assertThat(channel.getImportance()).isEqualTo(1);
}
@Test
@Config(minSdk = Build.VERSION_CODES.O)
public void deleteNotificationChannel() {
final String channelId = "channelId";
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.createNotificationChannel(new NotificationChannel(channelId, "name", 1));
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.deleteNotificationChannel(channelId);
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isTrue();
assertThat(notificationManager.getNotificationChannel(channelId)).isNull();
// Per documentation, recreating a deleted channel should have the same settings as the old
// deleted channel.
notificationManager.createNotificationChannel(
new NotificationChannel(channelId, "otherName", 2));
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
NotificationChannel channel = notificationManager.getNotificationChannel(channelId);
assertThat(channel.getName()).isEqualTo("name");
assertThat(channel.getImportance()).isEqualTo(1);
}
@Test
@Config(minSdk = Build.VERSION_CODES.O)
public void deleteNotificationChannelGroup() {
final String channelId = "channelId";
final String channelGroupId = "channelGroupId";
notificationManager.createNotificationChannelGroup(
new NotificationChannelGroup(channelGroupId, "groupName"));
NotificationChannel channel = new NotificationChannel(channelId, "channelName", 1);
channel.setGroup(channelGroupId);
notificationManager.createNotificationChannel(channel);
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.deleteNotificationChannelGroup(channelGroupId);
assertThat(shadowOf(notificationManager).getNotificationChannelGroup(channelGroupId)).isNull();
// Per documentation, deleting a channel group also deletes all associated channels.
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isTrue();
}
@Test
@Config(minSdk = Build.VERSION_CODES.N)
public void areNotificationsEnabled() {
shadowOf(notificationManager).setNotificationsEnabled(true);
assertThat(notificationManager.areNotificationsEnabled()).isTrue();
shadowOf(notificationManager).setNotificationsEnabled(false);
assertThat(notificationManager.areNotificationsEnabled()).isFalse();
}
@Test
>>>>>>>
@Config(minSdk = Build.VERSION_CODES.O)
public void createNotificationChannels() {
NotificationChannel channel1 = new NotificationChannel("id", "name", 1);
NotificationChannel channel2 = new NotificationChannel("id2", "name2", 1);
notificationManager.createNotificationChannels(ImmutableList.of(channel1, channel2));
assertThat(shadowOf(notificationManager).getNotificationChannels()).hasSize(2);
NotificationChannel channel =
(NotificationChannel) shadowOf(notificationManager).getNotificationChannel("id");
assertThat(channel.getName()).isEqualTo("name");
assertThat(channel.getImportance()).isEqualTo(1);
channel = (NotificationChannel) shadowOf(notificationManager).getNotificationChannel("id2");
assertThat(channel.getName()).isEqualTo("name2");
assertThat(channel.getImportance()).isEqualTo(1);
}
@Test
@Config(minSdk = Build.VERSION_CODES.O)
public void deleteNotificationChannel() {
final String channelId = "channelId";
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.createNotificationChannel(new NotificationChannel(channelId, "name", 1));
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.deleteNotificationChannel(channelId);
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isTrue();
assertThat(notificationManager.getNotificationChannel(channelId)).isNull();
// Per documentation, recreating a deleted channel should have the same settings as the old
// deleted channel.
notificationManager.createNotificationChannel(
new NotificationChannel(channelId, "otherName", 2));
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
NotificationChannel channel = notificationManager.getNotificationChannel(channelId);
assertThat(channel.getName()).isEqualTo("name");
assertThat(channel.getImportance()).isEqualTo(1);
}
@Test
@Config(minSdk = Build.VERSION_CODES.O)
public void deleteNotificationChannelGroup() {
final String channelId = "channelId";
final String channelGroupId = "channelGroupId";
notificationManager.createNotificationChannelGroup(
new NotificationChannelGroup(channelGroupId, "groupName"));
NotificationChannel channel = new NotificationChannel(channelId, "channelName", 1);
channel.setGroup(channelGroupId);
notificationManager.createNotificationChannel(channel);
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isFalse();
notificationManager.deleteNotificationChannelGroup(channelGroupId);
assertThat(shadowOf(notificationManager).getNotificationChannelGroup(channelGroupId)).isNull();
// Per documentation, deleting a channel group also deletes all associated channels.
assertThat(shadowOf(notificationManager).isChannelDeleted(channelId)).isTrue();
}
@Test
@Config(minSdk = Build.VERSION_CODES.N)
public void areNotificationsEnabled() {
shadowOf(notificationManager).setNotificationsEnabled(true);
assertThat(notificationManager.areNotificationsEnabled()).isTrue();
shadowOf(notificationManager).setNotificationsEnabled(false);
assertThat(notificationManager.areNotificationsEnabled()).isFalse();
}
@Test |
<<<<<<<
import android.os.Looper;
import android.test.mock.MockContentResolver;
=======
>>>>>>>
import android.os.Looper;
<<<<<<<
import android.widget.Toast;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;
=======
import com.xtremelabs.robolectric.Robolectric;
>>>>>>>
import android.widget.Toast;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;
<<<<<<<
private FakeHttpLayer fakeHttpLayer = new FakeHttpLayer();
private final Looper mainLooper = newInstanceOf(Looper.class);
private Looper currentLooper = mainLooper;
private Scheduler backgroundScheduler = new Scheduler();
private Map<String, Hashtable<String, Object>> sharedPreferenceMap = new HashMap<String, Hashtable<String, Object>>();
private ArrayList<Toast> shownToasts = new ArrayList<Toast>();
private ShadowAlertDialog latestAlertDialog;
private ShadowDialog latestDialog;
=======
private BluetoothAdapter bluetoothAdapter = Robolectric.newInstanceOf(BluetoothAdapter.class);
>>>>>>>
private FakeHttpLayer fakeHttpLayer = new FakeHttpLayer();
private final Looper mainLooper = newInstanceOf(Looper.class);
private Looper currentLooper = mainLooper;
private Scheduler backgroundScheduler = new Scheduler();
private Map<String, Hashtable<String, Object>> sharedPreferenceMap = new HashMap<String, Hashtable<String, Object>>();
private ArrayList<Toast> shownToasts = new ArrayList<Toast>();
private ShadowAlertDialog latestAlertDialog;
private ShadowDialog latestDialog;
private BluetoothAdapter bluetoothAdapter = Robolectric.newInstanceOf(BluetoothAdapter.class);
<<<<<<<
public FakeHttpLayer getFakeHttpLayer() {
return fakeHttpLayer;
}
@Override @Implementation
public Looper getMainLooper() {
return mainLooper;
}
public Looper getCurrentLooper() {
return currentLooper;
}
public Map<String,Hashtable<String, Object>> getSharedPreferenceMap() {
return sharedPreferenceMap;
}
public ShadowAlertDialog getLatestAlertDialog() {
return latestAlertDialog;
}
public void setLatestAlertDialog(ShadowAlertDialog latestAlertDialog) {
this.latestAlertDialog = latestAlertDialog;
}
public ShadowDialog getLatestDialog() {
return latestDialog;
}
public void setLatestDialog(ShadowDialog latestDialog) {
this.latestDialog = latestDialog;
}
=======
public BluetoothAdapter getBluetoothAdapter() {
return bluetoothAdapter;
}
>>>>>>>
public FakeHttpLayer getFakeHttpLayer() {
return fakeHttpLayer;
}
@Override @Implementation
public Looper getMainLooper() {
return mainLooper;
}
public Looper getCurrentLooper() {
return currentLooper;
}
public Map<String,Hashtable<String, Object>> getSharedPreferenceMap() {
return sharedPreferenceMap;
}
public ShadowAlertDialog getLatestAlertDialog() {
return latestAlertDialog;
}
public void setLatestAlertDialog(ShadowAlertDialog latestAlertDialog) {
this.latestAlertDialog = latestAlertDialog;
}
public ShadowDialog getLatestDialog() {
return latestDialog;
}
public void setLatestDialog(ShadowDialog latestDialog) {
this.latestDialog = latestDialog;
}
public BluetoothAdapter getBluetoothAdapter() {
return bluetoothAdapter;
} |
<<<<<<<
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
=======
import java.io.FileNotFoundException;
>>>>>>>
import java.io.FileNotFoundException;
<<<<<<<
import org.robolectric.res.android.BagAttributeFinder;
=======
import org.robolectric.res.android.Asset;
import org.robolectric.res.android.Asset.AccessMode;
>>>>>>>
import org.robolectric.res.android.BagAttributeFinder;
import org.robolectric.res.android.Asset;
import org.robolectric.res.android.Asset.AccessMode;
<<<<<<<
import org.robolectric.res.android.XmlAttributeFinder;
import org.robolectric.shadow.api.Shadow;
=======
>>>>>>>
import org.robolectric.res.android.XmlAttributeFinder;
import org.robolectric.shadow.api.Shadow;
<<<<<<<
=======
public static boolean isTruthy(int i) {
return i != 0;
}
public static boolean isTruthy(Object o) {
return o != null;
}
static void ALOGW(String message, Object... args) {
System.out.println("WARN: " + String.format(message, args));
}
public static void ALOGV(String message, Object... args) {
System.out.println("VERBOSE: " + String.format(message, args));
}
static void ALOGI(String message, Object... args) {
System.out.println("INFO: " + String.format(message, args));
}
static void ALOGE(String message, Object... args) {
System.out.println("ERROR: " + String.format(message, args));
}
>>>>>>>
public static boolean isTruthy(int i) {
return i != 0;
}
public static boolean isTruthy(Object o) {
return o != null;
}
static void ALOGW(String message, Object... args) {
System.out.println("WARN: " + String.format(message, args));
}
public static void ALOGV(String message, Object... args) {
System.out.println("VERBOSE: " + String.format(message, args));
}
static void ALOGI(String message, Object... args) {
System.out.println("INFO: " + String.format(message, args));
}
static void ALOGE(String message, Object... args) {
System.out.println("ERROR: " + String.format(message, args));
} |
<<<<<<<
import android.app.*;
=======
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Application;
import android.app.Dialog;
import android.app.KeyguardManager;
import android.app.ListActivity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.app.Service;
>>>>>>>
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Application;
import android.app.Dialog;
import android.app.KeyguardManager;
import android.app.ListActivity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.app.Service;
<<<<<<<
import android.graphics.*;
=======
import android.database.sqlite.SQLiteStatement;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
>>>>>>>
import android.database.sqlite.SQLiteStatement;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
<<<<<<<
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
=======
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.CountDownTimer;
>>>>>>>
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.CountDownTimer;
<<<<<<<
import android.telephony.TelephonyManager;
import android.view.*;
=======
import android.os.Parcel;
import android.os.PowerManager;
import android.os.ResultReceiver;
import android.preference.DialogPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.text.ClipboardManager;
import android.text.format.DateFormat;
import android.text.method.PasswordTransformationMethod;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
>>>>>>>
import android.os.Parcel;
import android.os.PowerManager;
import android.os.ResultReceiver;
import android.preference.DialogPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.text.ClipboardManager;
import android.text.format.DateFormat;
import android.text.method.PasswordTransformationMethod;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
<<<<<<<
import android.widget.*;
=======
import android.widget.AbsListView;
import android.widget.AbsSeekBar;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CursorAdapter;
import android.widget.ExpandableListView;
import android.widget.Filter;
import android.widget.FrameLayout;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.RemoteViews;
import android.widget.ResourceCursorAdapter;
import android.widget.SeekBar;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import android.widget.ViewAnimator;
import android.widget.ViewFlipper;
import android.widget.ZoomButtonsController;
>>>>>>>
import android.widget.AbsListView;
import android.widget.AbsSeekBar;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CursorAdapter;
import android.widget.ExpandableListView;
import android.widget.Filter;
import android.widget.FrameLayout;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.RemoteViews;
import android.widget.ResourceCursorAdapter;
import android.widget.SeekBar;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import android.widget.ViewAnimator;
import android.widget.ViewFlipper;
import android.widget.ZoomButtonsController;
<<<<<<<
ShadowAbsoluteLayout.ShadowLayoutParams.class,
=======
ShadowAbsSeekBar.class,
>>>>>>>
ShadowAbsoluteLayout.ShadowLayoutParams.class,
ShadowAbsSeekBar.class,
<<<<<<<
ShadowAnimationUtils.class,
=======
ShadowAndroidHttpClient.class,
ShadowAnimation.class,
ShadowAnimationUtils.class,
>>>>>>>
ShadowAndroidHttpClient.class,
ShadowAnimation.class,
ShadowAnimationUtils.class,
<<<<<<<
ShadowDateFormat.class,
=======
ShadowCookieSyncManager.class,
ShadowCountDownTimer.class,
ShadowCursorAdapter.class,
ShadowDatabaseUtils.class,
ShadowDateFormat.class,
>>>>>>>
ShadowCookieSyncManager.class,
ShadowCountDownTimer.class,
ShadowCursorAdapter.class,
ShadowDatabaseUtils.class,
ShadowDateFormat.class,
<<<<<<<
ShadowHtml.class,
=======
ShadowHandlerThread.class,
ShadowHtml.class,
>>>>>>>
ShadowHandlerThread.class,
ShadowHtml.class,
<<<<<<<
ShadowProgressBar.class,
=======
ShadowPreferenceScreen.class,
ShadowProgressBar.class,
ShadowProgressDialog.class,
ShadowRadioButton.class,
ShadowRadioGroup.class,
ShadowRatingBar.class,
>>>>>>>
ShadowPreferenceScreen.class,
ShadowProgressBar.class,
ShadowProgressDialog.class,
ShadowRadioButton.class,
ShadowRadioGroup.class,
ShadowRatingBar.class,
<<<<<<<
ShadowRectF.class,
=======
ShadowResolveInfo.class,
>>>>>>>
ShadowRectF.class,
ShadowResolveInfo.class,
<<<<<<<
ShadowSensorManager.class,
=======
ShadowScanResult.class,
ShadowSeekBar.class,
ShadowSensorManager.class,
>>>>>>>
ShadowScanResult.class,
ShadowSeekBar.class,
ShadowSensorManager.class,
<<<<<<<
ShadowSpannedString.class,
=======
ShadowSyncResult.class,
ShadowSyncResult.ShadowSyncStats.class,
ShadowSQLiteProgram.class,
>>>>>>>
ShadowSpannedString.class,
ShadowSyncResult.class,
ShadowSyncResult.ShadowSyncStats.class,
ShadowSQLiteProgram.class,
<<<<<<<
ShadowTelephonyManager.class,
=======
ShadowTabActivity.class,
ShadowTabHost.class,
ShadowTabSpec.class,
ShadowTelephonyManager.class,
>>>>>>>
ShadowTabActivity.class,
ShadowTabHost.class,
ShadowTabSpec.class,
ShadowTelephonyManager.class,
<<<<<<<
ShadowViewAnimator.class,
=======
ShadowViewAnimator.class,
ShadowViewConfiguration.class,
>>>>>>>
ShadowViewAnimator.class,
ShadowViewConfiguration.class,
<<<<<<<
ShadowWifiInfo.class,
=======
ShadowWifiConfiguration.class,
ShadowWifiInfo.class,
>>>>>>>
ShadowWifiConfiguration.class,
ShadowWifiInfo.class,
<<<<<<<
public static ShadowContentResolver shadowOf(ContentResolver instance) {
return (ShadowContentResolver) shadowOf_(instance);
}
public static ShadowContextWrapper shadowOf(ContextWrapper instance) {
return (ShadowContextWrapper) shadowOf_(instance);
=======
public static ShadowAnimationUtils shadowOf(AnimationUtils instance) {
return (ShadowAnimationUtils) shadowOf_(instance);
>>>>>>>
public static ShadowContentResolver shadowOf(ContentResolver instance) {
return (ShadowContentResolver) shadowOf_(instance);
}
public static ShadowContextWrapper shadowOf(ContextWrapper instance) {
return (ShadowContextWrapper) shadowOf_(instance);
}
public static ShadowAnimationUtils shadowOf(AnimationUtils instance) {
return (ShadowAnimationUtils) shadowOf_(instance);
<<<<<<<
public static ShadowProgressBar shadowOf(ProgressBar instance) {
return (ShadowProgressBar) shadowOf_(instance);
}
public static ShadowListActivity shadowOf(ListActivity instance) {
return (ShadowListActivity) shadowOf_(instance);
=======
public static ShadowAudioManager shadowOf(AudioManager instance) {
return (ShadowAudioManager) shadowOf_(instance);
>>>>>>>
public static ShadowAudioManager shadowOf(AudioManager instance) {
return (ShadowAudioManager) shadowOf_(instance);
}
public static ShadowProgressBar shadowOf(ProgressBar instance) {
return (ShadowProgressBar) shadowOf_(instance);
}
public static ShadowListActivity shadowOf(ListActivity instance) {
return (ShadowListActivity) shadowOf_(instance);
<<<<<<<
public static ShadowLocation shadowOf(Location instance) {
return (ShadowLocation) shadowOf_(instance);
}
public static ShadowAppWidgetManager shadowOf(AppWidgetManager instance) {
return (ShadowAppWidgetManager) shadowOf_(instance);
=======
public static ShadowExpandableListView shadowOf(ExpandableListView instance) {
return (ShadowExpandableListView) shadowOf_(instance);
>>>>>>>
public static ShadowExpandableListView shadowOf(ExpandableListView instance) {
return (ShadowExpandableListView) shadowOf_(instance);
}
public static ShadowLocation shadowOf(Location instance) {
return (ShadowLocation) shadowOf_(instance);
}
public static ShadowAppWidgetManager shadowOf(AppWidgetManager instance) {
return (ShadowAppWidgetManager) shadowOf_(instance);
<<<<<<<
public static void clearHttpResponseRules() {
getFakeHttpLayer().clearHttpResponseRules();
}
=======
public static void clearHttpResponseRules() {
getFakeHttpLayer().clearHttpResponseRules();
}
public static void clearPendingHttpResponses() {
getFakeHttpLayer().clearPendingHttpResponses();
}
>>>>>>>
public static void clearHttpResponseRules() {
getFakeHttpLayer().clearHttpResponseRules();
}
public static void clearPendingHttpResponses() {
getFakeHttpLayer().clearPendingHttpResponses();
} |
<<<<<<<
import android.app.Dialog;
import android.content.Context;
=======
import android.content.ComponentName;
>>>>>>>
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
<<<<<<<
import android.os.Bundle;
import android.view.*;
=======
import android.content.IntentSender;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.View;
import android.view.Window;
>>>>>>>
import android.content.IntentSender;
import android.os.Bundle;
import android.view.*;
<<<<<<<
@Implementation
public final void showDialog(int id) {
showDialog(id, null);
}
@Implementation
public final boolean showDialog(int id, Bundle bundle) {
Dialog dialog = null;
this.lastShownDialogId = id;
try {
Method method = Activity.class.getDeclaredMethod("onCreateDialog", Integer.TYPE);
method.setAccessible(true);
dialog = (Dialog) method.invoke(realActivity, id);
if (bundle == null) {
method = Activity.class.getDeclaredMethod("onPrepareDialog", Integer.TYPE, Dialog.class);
method.setAccessible(true);
method.invoke(realActivity, id, dialog);
} else {
method = Activity.class.getDeclaredMethod("onPrepareDialog", Integer.TYPE, Dialog.class, Bundle.class);
method.setAccessible(true);
method.invoke(realActivity, id, dialog, bundle);
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
dialog.show();
return true;
}
/**
* Non-Android accessor
*
* @return the dialog resource id passed into
* {@code Activity#showDialog(int, Bundle)} or {@code Activity#showDialog(int)}
*/
public Integer getLastShownDialogId() {
return lastShownDialogId;
}
=======
@Implementation
public ComponentName startService(Intent service) {
startServiceIntent = service;
return null;
}
/**
* Non-Android accessor.
*
* @return the {@code Intent} set by {@link #startService(android.content.Intent)}
*/
public Intent getStartServiceIntent() {
return startServiceIntent;
}
@Implementation
public void startIntentSender (IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
startIntentSenderIntent = intent;
startIntentSenderFillInIntent = fillInIntent;
startIntentSenderFlagsMask = flagsMask;
startIntentSenderFlagsValues = flagsValues;
startIntentSenderExtraFlags = extraFlags;
if (startIntentSenderShouldThrowException) {
throw new IntentSender.SendIntentException();
}
}
public void setStartIntentSenderShouldThrowException(boolean flag) {
startIntentSenderShouldThrowException = flag;
}
public IntentSender getStartIntentSenderIntent() {
return startIntentSenderIntent;
}
public Intent getStartIntentSenderFillInIntent() {
return startIntentSenderFillInIntent;
}
public int getStartIntentSenderFlagsMask() {
return startIntentSenderFlagsMask;
}
public int getStartIntentSenderFlagsValues() {
return startIntentSenderFlagsValues;
}
public int getStartIntentSenderExtraFlags() {
return startIntentSenderExtraFlags;
}
>>>>>>>
@Implementation
public final void showDialog(int id) {
showDialog(id, null);
}
@Implementation
public final boolean showDialog(int id, Bundle bundle) {
Dialog dialog = null;
this.lastShownDialogId = id;
try {
Method method = Activity.class.getDeclaredMethod("onCreateDialog", Integer.TYPE);
method.setAccessible(true);
dialog = (Dialog) method.invoke(realActivity, id);
if (bundle == null) {
method = Activity.class.getDeclaredMethod("onPrepareDialog", Integer.TYPE, Dialog.class);
method.setAccessible(true);
method.invoke(realActivity, id, dialog);
} else {
method = Activity.class.getDeclaredMethod("onPrepareDialog", Integer.TYPE, Dialog.class, Bundle.class);
method.setAccessible(true);
method.invoke(realActivity, id, dialog, bundle);
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
dialog.show();
return true;
}
/**
* Non-Android accessor
*
* @return the dialog resource id passed into
* {@code Activity#showDialog(int, Bundle)} or {@code Activity#showDialog(int)}
*/
public Integer getLastShownDialogId() {
return lastShownDialogId;
} |
<<<<<<<
public Intent putExtra(String key, String[] value) {
extras.put(key, value);
return realIntent;
}
@Implementation
public boolean hasExtra(String name) {
return extras.containsKey(name);
=======
public Intent putExtra(String key, int[] value) {
extras.put(key, value);
return realIntent;
}
@Implementation
public int[] getIntArrayExtra(String name) {
return (int[]) extras.get(name);
}
@Implementation
public boolean getBooleanExtra(String name, boolean defaultValue) {
return extras.containsKey(name) ? (Boolean) extras.get(name) : defaultValue;
}
@Implementation
public String[] getStringArrayExtra(String name) {
return (String[]) extras.get(name);
}
@Implementation
public Intent putExtra(String key, CharSequence value) {
extras.put(key, value);
return realIntent;
}
@Implementation
public CharSequence getCharSequenceExtra(String name) {
return (CharSequence) extras.get(name);
>>>>>>>
public Intent putExtra(String key, String[] value) {
extras.put(key, value);
return realIntent;
}
@Implementation
public boolean hasExtra(String name) {
return extras.containsKey(name);
}
public Intent putExtra(String key, int[] value) {
extras.put(key, value);
return realIntent;
}
@Implementation
public int[] getIntArrayExtra(String name) {
return (int[]) extras.get(name);
}
@Implementation
public boolean getBooleanExtra(String name, boolean defaultValue) {
return extras.containsKey(name) ? (Boolean) extras.get(name) : defaultValue;
}
@Implementation
public String[] getStringArrayExtra(String name) {
return (String[]) extras.get(name);
}
@Implementation
public Intent putExtra(String key, CharSequence value) {
extras.put(key, value);
return realIntent;
}
@Implementation
public CharSequence getCharSequenceExtra(String name) {
return (CharSequence) extras.get(name); |
<<<<<<<
=======
>>>>>>>
<<<<<<<
=======
>>>>>>>
<<<<<<<
@Implementation
=======
@Implementation
>>>>>>>
@Implementation
<<<<<<<
=======
>>>>>>> |
<<<<<<<
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
=======
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
>>>>>>>
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
<<<<<<<
import com.xtremelabs.robolectric.tester.android.util.TestAttributeSet;
=======
import com.xtremelabs.robolectric.util.TestAnimationListener;
>>>>>>>
import com.xtremelabs.robolectric.tester.android.util.TestAttributeSet;
import com.xtremelabs.robolectric.util.TestAnimationListener;
<<<<<<<
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
=======
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
>>>>>>>
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
<<<<<<<
@Before public void setUp() throws Exception {
transcript = new Transcript();
view = new View(null);
=======
@Before
public void setUp() throws Exception {
view = new View(new Activity());
>>>>>>>
@Before
public void setUp() throws Exception {
transcript = new Transcript();
view = new View(new Activity());
<<<<<<<
@Test
public void shouldRememberIsPressed() {
view.setPressed(true);
assertTrue(view.isPressed());
view.setPressed(false);
assertFalse(view.isPressed());
}
@Test
public void shouldAddOnClickListenerFromAttribute() throws Exception {
TestAttributeSet attrs = new TestAttributeSet();
attrs.put("android:onClick", "clickMe");
view = new View(null, attrs);
assertNotNull(shadowOf(view).getOnClickListener());
}
@Test
public void shouldCallOnClickWithAttribute() throws Exception {
final AtomicBoolean called = new AtomicBoolean(false);
Activity context = new Activity() {
public void clickMe(View view) {
called.set(true);
}
};
TestAttributeSet attrs = new TestAttributeSet();
attrs.put("android:onClick", "clickMe");
view = new View(context, attrs);
view.performClick();
assertTrue("Should have been called", called.get());
}
@Test(expected = RuntimeException.class)
public void shouldThrowExceptionWithBadMethodName() throws Exception {
final AtomicBoolean called = new AtomicBoolean(false);
Activity context = new Activity() {
public void clickMe(View view) {
called.set(true);
}
};
TestAttributeSet attrs = new TestAttributeSet();
attrs.put("android:onClick", "clickYou");
view = new View(context, attrs);
view.performClick();
}
=======
@Test
public void shouldSetAnimation() throws Exception {
Animation anim = new TestAnimation();
view.setAnimation(anim);
assertThat(view.getAnimation(), sameInstance(anim));
}
@Test
public void shouldStartAndClearAnimation() throws Exception {
Animation anim = new TestAnimation();
TestAnimationListener listener = new TestAnimationListener();
anim.setAnimationListener(listener);
assertThat(listener.wasStartCalled, equalTo(false));
assertThat(listener.wasRepeatCalled, equalTo(false));
assertThat(listener.wasEndCalled, equalTo(false));
view.startAnimation(anim);
assertThat(listener.wasStartCalled, equalTo(true));
assertThat(listener.wasRepeatCalled, equalTo(false));
assertThat(listener.wasEndCalled, equalTo(false));
view.clearAnimation();
assertThat(listener.wasStartCalled, equalTo(true));
assertThat(listener.wasRepeatCalled, equalTo(false));
assertThat(listener.wasEndCalled, equalTo(true));
}
@Test
public void shouldfindViewWithTag() {
String tagged = "tagged";
String tagged2 = "tagged";
view.setTag(tagged);
assertThat(view.findViewWithTag(tagged2),sameInstance(view));
}
@Test
public void scrollTo_shouldStoreTheScrolledCoordinates() throws Exception {
view.scrollTo(1, 2);
assertThat(shadowOf(view).scrollToCoordinates, equalTo(new Point(1, 2)));
}
private class TestAnimation extends Animation {
}
>>>>>>>
@Test
public void shouldRememberIsPressed() {
view.setPressed(true);
assertTrue(view.isPressed());
view.setPressed(false);
assertFalse(view.isPressed());
}
@Test
public void shouldAddOnClickListenerFromAttribute() throws Exception {
TestAttributeSet attrs = new TestAttributeSet();
attrs.put("android:onClick", "clickMe");
view = new View(null, attrs);
assertNotNull(shadowOf(view).getOnClickListener());
}
@Test
public void shouldCallOnClickWithAttribute() throws Exception {
final AtomicBoolean called = new AtomicBoolean(false);
Activity context = new Activity() {
public void clickMe(View view) {
called.set(true);
}
};
TestAttributeSet attrs = new TestAttributeSet();
attrs.put("android:onClick", "clickMe");
view = new View(context, attrs);
view.performClick();
assertTrue("Should have been called", called.get());
}
@Test(expected = RuntimeException.class)
public void shouldThrowExceptionWithBadMethodName() throws Exception {
final AtomicBoolean called = new AtomicBoolean(false);
Activity context = new Activity() {
public void clickMe(View view) {
called.set(true);
}
};
TestAttributeSet attrs = new TestAttributeSet();
attrs.put("android:onClick", "clickYou");
view = new View(context, attrs);
view.performClick();
}
@Test
public void shouldSetAnimation() throws Exception {
Animation anim = new TestAnimation();
view.setAnimation(anim);
assertThat(view.getAnimation(), sameInstance(anim));
}
@Test
public void shouldStartAndClearAnimation() throws Exception {
Animation anim = new TestAnimation();
TestAnimationListener listener = new TestAnimationListener();
anim.setAnimationListener(listener);
assertThat(listener.wasStartCalled, equalTo(false));
assertThat(listener.wasRepeatCalled, equalTo(false));
assertThat(listener.wasEndCalled, equalTo(false));
view.startAnimation(anim);
assertThat(listener.wasStartCalled, equalTo(true));
assertThat(listener.wasRepeatCalled, equalTo(false));
assertThat(listener.wasEndCalled, equalTo(false));
view.clearAnimation();
assertThat(listener.wasStartCalled, equalTo(true));
assertThat(listener.wasRepeatCalled, equalTo(false));
assertThat(listener.wasEndCalled, equalTo(true));
}
@Test
public void shouldfindViewWithTag() {
String tagged = "tagged";
String tagged2 = "tagged";
view.setTag(tagged);
assertThat(view.findViewWithTag(tagged2),sameInstance(view));
}
@Test
public void scrollTo_shouldStoreTheScrolledCoordinates() throws Exception {
view.scrollTo(1, 2);
assertThat(shadowOf(view).scrollToCoordinates, equalTo(new Point(1, 2)));
}
private class TestAnimation extends Animation {
} |
<<<<<<<
private long downTime;
private long eventTime;
=======
private int pointerCount = 1;
>>>>>>>
private int pointerCount = 1;
private long downTime;
private long eventTime; |
<<<<<<<
private boolean interceptHttpRequests = true;
=======
private boolean logHttpRequests = false;
>>>>>>>
private boolean interceptHttpRequests = true;
private boolean logHttpRequests = false; |
<<<<<<<
import static android.graphics.Shader.TileMode;
=======
import static com.xtremelabs.robolectric.Robolectric.newInstanceOf;
>>>>>>>
import static android.graphics.Shader.TileMode;
import static com.xtremelabs.robolectric.Robolectric.newInstanceOf; |
<<<<<<<
public static long getSumTotalTermFreq(IndexReader reader, String luceneField) {
long totalTerms = 0;
try {
for (LeafReaderContext ctx: reader.leaves()) {
Terms terms = ctx.reader().terms(luceneField);
if (terms == null)
throw new RuntimeException("Field " + luceneField + " does not exist!");
totalTerms += terms.getSumTotalTermFreq();
}
return totalTerms;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
=======
/**
* Enumerate all the terms in the given Lucene field, collecting all the subproperty
* names and values. Usually used for part of speech, where all the features are stored
* as separate subproperties.
*
* @param index our index
* @param fieldName field in the Lucene index to enumerate terms from
* @return subproperties and their values
*/
public static Map<String, Set<String>> getSubprops(IndexReader index, String fieldName) {
Map<String, Set<String>> results = new TreeMap<>();
try {
for (LeafReaderContext leafReader: index.leaves()) {
Terms terms = leafReader.reader().terms(fieldName);
TermsEnum termsEnum = terms.iterator();
while (true) {
BytesRef term = termsEnum.next();
if (term == null)
break;
String termText = term.utf8ToString();
if (termText.contains(ComplexFieldUtil.ASCII_UNIT_SEPARATOR)) {
termText = StringUtil.removeAccents(termText).toLowerCase();
String[] parts = termText.split(ComplexFieldUtil.ASCII_UNIT_SEPARATOR);
String subpropName = parts[0];
Set<String> resultList = results.get(subpropName);
if (resultList == null) {
resultList = new TreeSet<>();
results.put(subpropName, resultList);
}
String subpropValue = parts[1];
resultList.add(subpropValue);
}
}
}
return results;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
>>>>>>>
public static long getSumTotalTermFreq(IndexReader reader, String luceneField) {
long totalTerms = 0;
try {
for (LeafReaderContext ctx: reader.leaves()) {
Terms terms = ctx.reader().terms(luceneField);
if (terms == null)
throw new RuntimeException("Field " + luceneField + " does not exist!");
totalTerms += terms.getSumTotalTermFreq();
}
return totalTerms;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* Enumerate all the terms in the given Lucene field, collecting all the subproperty
* names and values. Usually used for part of speech, where all the features are stored
* as separate subproperties.
*
* @param index our index
* @param fieldName field in the Lucene index to enumerate terms from
* @return subproperties and their values
*/
public static Map<String, Set<String>> getSubprops(IndexReader index, String fieldName) {
Map<String, Set<String>> results = new TreeMap<>();
try {
for (LeafReaderContext leafReader: index.leaves()) {
Terms terms = leafReader.reader().terms(fieldName);
TermsEnum termsEnum = terms.iterator();
while (true) {
BytesRef term = termsEnum.next();
if (term == null)
break;
String termText = term.utf8ToString();
if (termText.contains(ComplexFieldUtil.ASCII_UNIT_SEPARATOR)) {
termText = StringUtil.removeAccents(termText).toLowerCase();
String[] parts = termText.split(ComplexFieldUtil.ASCII_UNIT_SEPARATOR);
String subpropName = parts[0];
Set<String> resultList = results.get(subpropName);
if (resultList == null) {
resultList = new TreeSet<>();
results.put(subpropName, resultList);
}
String subpropValue = parts[1];
resultList.add(subpropValue);
}
}
}
return results;
} catch (IOException e) {
throw new RuntimeException(e);
}
} |
<<<<<<<
import android.location.Location;
import android.location.LocationListener;
=======
import java.util.LinkedHashSet;
import java.util.Set;
import android.location.Criteria;
import android.location.GpsStatus.Listener;
import android.location.Location;
import android.location.LocationListener;
>>>>>>>
import java.util.LinkedHashSet;
import java.util.Set;
import android.location.Criteria;
import android.location.GpsStatus.Listener;
import android.location.Location;
import android.location.LocationListener;
<<<<<<<
import java.util.ArrayList;
=======
import java.util.ArrayList;
>>>>>>>
import java.util.ArrayList;
<<<<<<<
private Location simulatedLocation = null;
/** Location listeners along with metadata on when they should be fired. */
private static final class ListenerRegistration {
final long minTime;
final float minDistance;
Location lastSeenLocation;
long lastSeenTime;
final LocationListener listener;
ListenerRegistration(long minTime, float minDistance, Location locationAtCreation,
LocationListener listener) {
this.minTime = minTime;
this.minDistance = minDistance;
this.lastSeenTime = locationAtCreation == null ? 0 : locationAtCreation.getTime();
this.lastSeenLocation = locationAtCreation;
this.listener = listener;
}
}
/** Mapped by provider. */
private final Map<String, List<ListenerRegistration>> locationListeners =
new HashMap<String, List<ListenerRegistration>>();
@Implementation
public List<String> getAllProviders() {
return new ArrayList<String>(providersEnabled.keySet());
}
=======
private final Map<String, Location> lastKnownLocations = new HashMap<String, Location>();
private final ArrayList<Listener> gpsStatusListeners = new ArrayList<Listener>();
private Criteria lastBestProviderCriteria;
private boolean lastBestProviderEnabledOnly;
private String bestProvider;
private List<LocationListener> requestLocationUdpateListeners = new ArrayList<LocationListener>();
>>>>>>>
private final Map<String, Location> lastKnownLocations = new HashMap<String, Location>();
private final ArrayList<Listener> gpsStatusListeners = new ArrayList<Listener>();
private Criteria lastBestProviderCriteria;
private boolean lastBestProviderEnabledOnly;
private String bestProvider;
private List<LocationListener> requestLocationUdpateListeners = new ArrayList<LocationListener>();
@Implementation
public List<String> getAllProviders() {
return new ArrayList<String>(providersEnabled.keySet());
}
<<<<<<<
@Implementation
public Location getLastKnownLocation(String provider) {
return simulatedLocation;
}
@Implementation
public void requestLocationUpdates(String provider,
long minTime, float minDistance, LocationListener listener) {
List<ListenerRegistration> providerListeners = locationListeners.get(provider);
if (providerListeners == null) {
providerListeners = new ArrayList<ListenerRegistration>();
locationListeners.put(provider, providerListeners);
}
providerListeners.add(new ListenerRegistration(
minTime, minDistance, copyOf(simulatedLocation), listener));
}
public void simulateLocation(Location location) {
simulatedLocation = location;
List<ListenerRegistration> providerListeners = locationListeners.get(
location.getProvider());
if (providerListeners == null) return;
for (ListenerRegistration listenerReg : providerListeners) {
if(listenerReg.lastSeenLocation != null && simulatedLocation != null) {
float distanceChange = distanceBetween(simulatedLocation, listenerReg.lastSeenLocation);
boolean withinMinDistance = distanceChange < listenerReg.minDistance;
boolean exceededMinTime = location.getTime() - listenerReg.lastSeenTime > listenerReg.minTime;
if (withinMinDistance && !exceededMinTime) continue;
}
listenerReg.lastSeenLocation = copyOf(location);
listenerReg.lastSeenTime = location == null ? 0 : location.getTime();
listenerReg.listener.onLocationChanged(copyOf(location));
}
}
private Location copyOf(Location location) {
if (location == null) return null;
Location copy = new Location(location);
copy.setAccuracy(location.getAccuracy());
copy.setAltitude(location.getAltitude());
copy.setBearing(location.getBearing());
copy.setExtras(location.getExtras());
copy.setLatitude(location.getLatitude());
copy.setLongitude(location.getLongitude());
copy.setProvider(location.getProvider());
copy.setSpeed(location.getSpeed());
copy.setTime(location.getTime());
return copy;
}
/**
* Returns the distance between the two locations in meters.
* Adapted from: http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java
*/
private static float distanceBetween(Location location1, Location location2) {
double earthRadius = 3958.75;
double latDifference = Math.toRadians(location2.getLatitude() - location1.getLatitude());
double lonDifference = Math.toRadians(location2.getLongitude() - location2.getLongitude());
double a = Math.sin(latDifference/2) * Math.sin(latDifference/2) +
Math.cos(Math.toRadians(location1.getLatitude())) * Math.cos(Math.toRadians(location2.getLatitude())) *
Math.sin(lonDifference/2) * Math.sin(lonDifference/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double dist = Math.abs(earthRadius * c);
int meterConversion = 1609;
return new Float(dist * meterConversion).floatValue();
}
=======
@Implementation
public List<String> getProviders(boolean enabledOnly) {
ArrayList<String> enabledProviders = new ArrayList<String>();
for (Map.Entry<String, Boolean> entry : providersEnabled.entrySet()) {
if (entry.getValue()) {
enabledProviders.add(entry.getKey());
}
}
return enabledProviders;
}
@Implementation
public Location getLastKnownLocation(String provider) {
return lastKnownLocations.get(provider);
}
@Implementation
public boolean addGpsStatusListener(Listener listener) {
if (!gpsStatusListeners.contains(listener)) {
gpsStatusListeners.add(listener);
}
return true;
}
@Implementation
public void removeGpsStatusListener(Listener listener) {
gpsStatusListeners.remove(listener);
}
@Implementation
public String getBestProvider(android.location.Criteria criteria, boolean enabledOnly) {
lastBestProviderCriteria = criteria;
lastBestProviderEnabledOnly = enabledOnly;
return bestProvider;
}
@Implementation
public void requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener) {
requestLocationUdpateListeners.add(listener);
}
@Implementation
public void removeUpdates(LocationListener listener) {
while (requestLocationUdpateListeners.remove(listener));
}
public boolean hasGpsStatusListener(Listener listener) {
return gpsStatusListeners.contains(listener);
}
/**
* Non-Android accessor.
* <p/>
* Gets the criteria value used in the last call to {@link #getBestProvider(android.location.Criteria, boolean)}
*
* @return the criteria used to find the best provider
*/
public Criteria getLastBestProviderCriteria() {
return lastBestProviderCriteria;
}
/**
* Non-Android accessor.
* <p/>
* Gets the enabled value used in the last call to {@link #getBestProvider(android.location.Criteria, boolean)}
*
* @return the enabled value used to find the best provider
*/
public boolean getLastBestProviderEnabledOnly() {
return lastBestProviderEnabledOnly;
}
/**
* Sets the value to return from {@link #getBestProvider(android.location.Criteria, boolean)}
* for the given {@code provider}
*
* @param provider name of the provider who should be considered best
*/
public void setBestProvider(String provider) {
bestProvider = provider;
}
/**
* Sets the value to return from {@link #getLastKnownLocation(String)} for the given {@code provider}
*
* @param provider name of the provider whose location to set
* @param location the last known location for the provider
*/
public void setLastKnownLocation(String provider, Location location) {
lastKnownLocations.put(provider, location);
}
/**
* Non-Android accessor.
*
* @return lastRequestedLocationUpdatesLocationListener
*/
public List<LocationListener> getRequestLocationUpdateListeners() {
return requestLocationUdpateListeners;
}
>>>>>>>
@Implementation
public List<String> getProviders(boolean enabledOnly) {
ArrayList<String> enabledProviders = new ArrayList<String>();
for (Map.Entry<String, Boolean> entry : providersEnabled.entrySet()) {
if (entry.getValue()) {
enabledProviders.add(entry.getKey());
}
}
return enabledProviders;
}
@Implementation
public Location getLastKnownLocation(String provider) {
return lastKnownLocations.get(provider);
}
@Implementation
public boolean addGpsStatusListener(Listener listener) {
if (!gpsStatusListeners.contains(listener)) {
gpsStatusListeners.add(listener);
}
return true;
}
@Implementation
public void removeGpsStatusListener(Listener listener) {
gpsStatusListeners.remove(listener);
}
@Implementation
public String getBestProvider(android.location.Criteria criteria, boolean enabledOnly) {
lastBestProviderCriteria = criteria;
lastBestProviderEnabledOnly = enabledOnly;
return bestProvider;
}
@Implementation
public void requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener) {
requestLocationUdpateListeners.add(listener);
}
@Implementation
public void removeUpdates(LocationListener listener) {
while (requestLocationUdpateListeners.remove(listener));
}
public boolean hasGpsStatusListener(Listener listener) {
return gpsStatusListeners.contains(listener);
}
/**
* Non-Android accessor.
* <p/>
* Gets the criteria value used in the last call to {@link #getBestProvider(android.location.Criteria, boolean)}
*
* @return the criteria used to find the best provider
*/
public Criteria getLastBestProviderCriteria() {
return lastBestProviderCriteria;
}
/**
* Non-Android accessor.
* <p/>
* Gets the enabled value used in the last call to {@link #getBestProvider(android.location.Criteria, boolean)}
*
* @return the enabled value used to find the best provider
*/
public boolean getLastBestProviderEnabledOnly() {
return lastBestProviderEnabledOnly;
}
/**
* Sets the value to return from {@link #getBestProvider(android.location.Criteria, boolean)}
* for the given {@code provider}
*
* @param provider name of the provider who should be considered best
*/
public void setBestProvider(String provider) {
bestProvider = provider;
}
/**
* Sets the value to return from {@link #getLastKnownLocation(String)} for the given {@code provider}
*
* @param provider name of the provider whose location to set
* @param location the last known location for the provider
*/
public void setLastKnownLocation(String provider, Location location) {
lastKnownLocations.put(provider, location);
}
/**
* Non-Android accessor.
*
* @return lastRequestedLocationUpdatesLocationListener
*/
public List<LocationListener> getRequestLocationUpdateListeners() {
return requestLocationUdpateListeners;
} |
<<<<<<<
import static android.os.Build.VERSION_CODES.P;
import static org.robolectric.Shadows.shadowOf;
=======
>>>>>>>
<<<<<<<
import android.os.Build;
import android.view.ContextThemeWrapper;
=======
>>>>>>> |
<<<<<<<
import com.xtremelabs.robolectric.TestRunners;
=======
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
>>>>>>>
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.TestRunners; |
<<<<<<<
@Override
public float getAttributeFloatValue(String namespace, String attribute, float defaultValue) {
String value = getAttributeValueInMap(namespace, attribute);
if (attrResourceLoader.hasAttributeFor(viewClass, "xxx", attribute)) {
value = attrResourceLoader.convertValueToEnum(viewClass, "xxx", attribute, value);
}
return (value != null) ? Float.valueOf(value) : defaultValue;
=======
@Override public float getAttributeFloatValue(String namespace, String attribute, float defaultValue) {
String value = getAttributeValueInMap(attribute);
return (value != null) ? Float.valueOf(value) : defaultValue;
>>>>>>>
@Override
public float getAttributeFloatValue(String namespace, String attribute, float defaultValue) {
String value = getAttributeValueInMap(namespace, attribute);
return (value != null) ? Float.valueOf(value) : defaultValue;
<<<<<<<
@Override
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
String value = getAttributeValueInMap(namespace, attribute);
return (value != null) ? resourceExtractor.getResourceId(value) : defaultValue;
=======
@Override public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
String value = getAttributeValueInMap(attribute);
Integer resourceId = null;
if (value != null) resourceId = resourceExtractor.getResourceId(value);
return (resourceId != null) ? resourceId : defaultValue;
>>>>>>>
@Override public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
String value = getAttributeValueInMap(namespace, attribute);
Integer resourceId = null;
if (value != null) resourceId = resourceExtractor.getResourceId(value);
return (resourceId != null) ? resourceId : defaultValue;
<<<<<<<
String value = getAttributeValueInMap(null, attrName);
return (value == null) ? defaultValue : resourceExtractor.getResourceId(value);
=======
String value = getAttributeValueInMap(attrName);
Integer extracted = null;
if (value != null) extracted = resourceExtractor.getResourceId(value);
return (extracted == null) ? defaultValue : extracted;
>>>>>>>
String value = getAttributeValueInMap(null, attrName);
Integer extracted = null;
if (value != null) extracted = resourceExtractor.getResourceId(value);
return (extracted == null) ? defaultValue : extracted;
<<<<<<<
@Override
public int getStyleAttribute() {
throw new UnsupportedOperationException();
=======
@Override public int getStyleAttribute() {
String value = attributes.get("style");
if (value == null) {
// Per Android specifications, return 0 if there is no style.
return 0;
}
if (resourceExtractor != null) {
Integer i = resourceExtractor.getResourceId(value);
if (i != null) return i;
}
return 0;
>>>>>>>
@Override public int getStyleAttribute() {
String value = attributes.get("style");
if (value == null) {
// Per Android specifications, return 0 if there is no style.
return 0;
}
if (resourceExtractor != null) {
Integer i = resourceExtractor.getResourceId(value);
if (i != null) return i;
}
return 0; |
<<<<<<<
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
=======
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
>>>>>>>
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
<<<<<<<
=======
textView.setText("text");
assertEachTextWatcherEventWasInvoked(mockTextWatcher);
}
>>>>>>>
<<<<<<<
return mockTextWatchers;
}
private void assertEachTextWatcherEventWasInvoked(MockTextWatcher mockTextWatcher) {
assertTrue("Expected each TextWatcher event to have been invoked once", mockTextWatcher.methodsCalled.size() == 3);
assertThat(mockTextWatcher.methodsCalled.get(0), equalTo("beforeTextChanged"));
assertThat(mockTextWatcher.methodsCalled.get(1), equalTo("onTextChanged"));
assertThat(mockTextWatcher.methodsCalled.get(2), equalTo("afterTextChanged"));
}
private List<String> urlStringsFrom(URLSpan[] urlSpans) {
=======
return mockTextWatchers;
}
private void assertEachTextWatcherEventWasInvoked(MockTextWatcher mockTextWatcher) {
assertTrue("Expected each TextWatcher event to have been invoked once", mockTextWatcher.methodsCalled.size() == 3);
assertThat(mockTextWatcher.methodsCalled.get(0), equalTo("beforeTextChanged"));
assertThat(mockTextWatcher.methodsCalled.get(1), equalTo("onTextChanged"));
assertThat(mockTextWatcher.methodsCalled.get(2), equalTo("afterTextChanged"));
}
private List<String> urlStringsFrom(URLSpan[] urlSpans) {
>>>>>>>
return mockTextWatchers;
}
private void assertEachTextWatcherEventWasInvoked(MockTextWatcher mockTextWatcher) {
assertTrue("Expected each TextWatcher event to have been invoked once", mockTextWatcher.methodsCalled.size() == 3);
assertThat(mockTextWatcher.methodsCalled.get(0), equalTo("beforeTextChanged"));
assertThat(mockTextWatcher.methodsCalled.get(1), equalTo("onTextChanged"));
assertThat(mockTextWatcher.methodsCalled.get(2), equalTo("afterTextChanged"));
}
private List<String> urlStringsFrom(URLSpan[] urlSpans) {
<<<<<<<
List<String> methodsCalled = new ArrayList<String>();
Editable afterTextChangeArgument;
=======
List<String> methodsCalled = new ArrayList<String>();
Editable afterTextChangeArgument;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
methodsCalled.add("beforeTextChanged");
}
>>>>>>>
List<String> methodsCalled = new ArrayList<String>();
Editable afterTextChangeArgument;
<<<<<<<
=======
>>>>>>> |
<<<<<<<
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.TestRunners;
=======
import org.robolectric.RobolectricTestRunner;
>>>>>>>
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
<<<<<<<
private Context context;
=======
private Activity context;
private String testPackageName;
>>>>>>>
private Context context;
private String testPackageName;
<<<<<<<
context = RuntimeEnvironment.application;
=======
context = buildActivity(Activity.class).create().get();
testPackageName = context.getPackageName();
>>>>>>>
context = RuntimeEnvironment.application;
testPackageName = context.getPackageName();
<<<<<<<
int layoutResId1 = activity.getResources().getIdentifier("multi_orientation", "layout", TEST_PACKAGE);
ViewGroup view = (ViewGroup) LayoutInflater.from(activity).inflate(layoutResId1, null);
assertInstanceOf(LinearLayout.class, view);
=======
int layoutResId1 = context.getResources().getIdentifier("multi_orientation", "layout",
testPackageName);
ViewGroup view = (ViewGroup) LayoutInflater.from(context).inflate(layoutResId1, null);
assertThat(view).isInstanceOf((Class<? extends ViewGroup>) LinearLayout.class);
>>>>>>>
int layoutResId1 = activity.getResources().getIdentifier("multi_orientation", "layout",
testPackageName);
ViewGroup view = (ViewGroup) LayoutInflater.from(activity).inflate(layoutResId1, null);
assertThat(view).isInstanceOf((Class<? extends ViewGroup>) LinearLayout.class);
<<<<<<<
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
int layoutResId = activity.getResources().getIdentifier("multi_orientation", "layout", TEST_PACKAGE);
view = (ViewGroup) LayoutInflater.from(activity).inflate(layoutResId, null);
assertInstanceOf(LinearLayout.class, view);
=======
context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
int layoutResId = context.getResources().getIdentifier("multi_orientation", "layout",
testPackageName);
view = (ViewGroup) LayoutInflater.from(context).inflate(layoutResId, null);
assertThat(view).isInstanceOf((Class<? extends ViewGroup>) LinearLayout.class);
>>>>>>>
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
int layoutResId = activity.getResources().getIdentifier("multi_orientation", "layout",
testPackageName);
view = (ViewGroup) LayoutInflater.from(activity).inflate(layoutResId, null);
assertThat(view).isInstanceOf((Class<? extends ViewGroup>) LinearLayout.class);
<<<<<<<
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
int layoutResId = activity.getResources().getIdentifier("multi_orientation", "layout", TEST_PACKAGE);
ViewGroup view = (ViewGroup) LayoutInflater.from(activity).inflate(layoutResId, null);
=======
context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
int layoutResId = context.getResources().getIdentifier("multi_orientation", "layout",
testPackageName);
ViewGroup view = (ViewGroup) LayoutInflater.from(context).inflate(layoutResId, null);
>>>>>>>
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
int layoutResId = activity.getResources().getIdentifier("multi_orientation", "layout",
testPackageName);
ViewGroup view = (ViewGroup) LayoutInflater.from(activity).inflate(layoutResId, null); |
<<<<<<<
=======
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
>>>>>>>
import org.robolectric.Robolectric; |
<<<<<<<
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testGetAppStandbyBucket_withPackageName() throws Exception {
shadowUsageStatsManager.setAppStandbyBucket("app1", UsageStatsManager.STANDBY_BUCKET_RARE);
assertThat(shadowUsageStatsManager.getAppStandbyBucket("app1"))
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_RARE);
assertThat(shadowUsageStatsManager.getAppStandbyBucket("app_unset"))
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_ACTIVE);
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testGetAppStandbyBucket_currentApp() throws Exception {
shadowUsageStatsManager.setCurrentAppStandbyBucket(UsageStatsManager.STANDBY_BUCKET_RARE);
assertThat(shadowUsageStatsManager.getAppStandbyBucket())
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_RARE);
ShadowUsageStatsManager.reset();
assertThat(shadowUsageStatsManager.getAppStandbyBucket())
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_ACTIVE);
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testRegisterAppUsageObserver_uniqueObserverIds_shouldAddBothObservers() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12,
ImmutableList.of("com.package1", "com.package2"),
123L,
TimeUnit.MINUTES,
pendingIntent1),
new AppUsageObserver(
24, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testRegisterAppUsageObserver_duplicateObserverIds_shouldOverrideExistingObserver() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testUnregisterAppUsageObserver_existingObserverId_shouldRemoveObserver() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
usageStatsManager.unregisterAppUsageObserver(12);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
24, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testUnregisterAppUsageObserver_nonExistentObserverId_shouldBeNoOp() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
usageStatsManager.unregisterAppUsageObserver(36);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12,
ImmutableList.of("com.package1", "com.package2"),
123L,
TimeUnit.MINUTES,
pendingIntent1),
new AppUsageObserver(
24, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testTriggerRegisteredAppUsageObserver_shouldSendIntentAndRemoveObserver() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
shadowUsageStatsManager.triggerRegisteredAppUsageObserver(24, 500000L);
List<Intent> broadcastIntents = ShadowApplication.getInstance().getBroadcastIntents();
assertThat(broadcastIntents).hasSize(1);
Intent broadcastIntent = broadcastIntents.get(0);
assertThat(broadcastIntent.getAction()).isEqualTo("ACTION2");
assertThat(broadcastIntent.getIntExtra(UsageStatsManager.EXTRA_OBSERVER_ID, 0)).isEqualTo(24);
assertThat(broadcastIntent.getLongExtra(UsageStatsManager.EXTRA_TIME_LIMIT, 0))
.isEqualTo(456000L);
assertThat(broadcastIntent.getLongExtra(UsageStatsManager.EXTRA_TIME_USED, 0))
.isEqualTo(500000L);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12,
ImmutableList.of("com.package1", "com.package2"),
123L,
TimeUnit.MINUTES,
pendingIntent1));
}
=======
>>>>>>>
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testGetAppStandbyBucket_withPackageName() throws Exception {
shadowUsageStatsManager.setAppStandbyBucket("app1", UsageStatsManager.STANDBY_BUCKET_RARE);
assertThat(shadowUsageStatsManager.getAppStandbyBucket("app1"))
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_RARE);
assertThat(shadowUsageStatsManager.getAppStandbyBucket("app_unset"))
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_ACTIVE);
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testGetAppStandbyBucket_currentApp() throws Exception {
shadowUsageStatsManager.setCurrentAppStandbyBucket(UsageStatsManager.STANDBY_BUCKET_RARE);
assertThat(shadowUsageStatsManager.getAppStandbyBucket())
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_RARE);
ShadowUsageStatsManager.reset();
assertThat(shadowUsageStatsManager.getAppStandbyBucket())
.isEqualTo(UsageStatsManager.STANDBY_BUCKET_ACTIVE);
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testRegisterAppUsageObserver_uniqueObserverIds_shouldAddBothObservers() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12,
ImmutableList.of("com.package1", "com.package2"),
123L,
TimeUnit.MINUTES,
pendingIntent1),
new AppUsageObserver(
24, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testRegisterAppUsageObserver_duplicateObserverIds_shouldOverrideExistingObserver() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testUnregisterAppUsageObserver_existingObserverId_shouldRemoveObserver() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
usageStatsManager.unregisterAppUsageObserver(12);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
24, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testUnregisterAppUsageObserver_nonExistentObserverId_shouldBeNoOp() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
usageStatsManager.unregisterAppUsageObserver(36);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12,
ImmutableList.of("com.package1", "com.package2"),
123L,
TimeUnit.MINUTES,
pendingIntent1),
new AppUsageObserver(
24, ImmutableList.of("com.package3"), 456L, TimeUnit.SECONDS, pendingIntent2));
}
@Test
@Config(minSdk = Build.VERSION_CODES.P)
public void testTriggerRegisteredAppUsageObserver_shouldSendIntentAndRemoveObserver() {
PendingIntent pendingIntent1 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION1"), 0);
usageStatsManager.registerAppUsageObserver(
12, new String[] {"com.package1", "com.package2"}, 123L, TimeUnit.MINUTES, pendingIntent1);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(RuntimeEnvironment.application, 0, new Intent("ACTION2"), 0);
usageStatsManager.registerAppUsageObserver(
24, new String[] {"com.package3"}, 456L, TimeUnit.SECONDS, pendingIntent2);
shadowUsageStatsManager.triggerRegisteredAppUsageObserver(24, 500000L);
List<Intent> broadcastIntents = ShadowApplication.getInstance().getBroadcastIntents();
assertThat(broadcastIntents).hasSize(1);
Intent broadcastIntent = broadcastIntents.get(0);
assertThat(broadcastIntent.getAction()).isEqualTo("ACTION2");
assertThat(broadcastIntent.getIntExtra(UsageStatsManager.EXTRA_OBSERVER_ID, 0)).isEqualTo(24);
assertThat(broadcastIntent.getLongExtra(UsageStatsManager.EXTRA_TIME_LIMIT, 0))
.isEqualTo(456000L);
assertThat(broadcastIntent.getLongExtra(UsageStatsManager.EXTRA_TIME_USED, 0))
.isEqualTo(500000L);
assertThat(shadowUsageStatsManager.getRegisteredAppUsageObservers())
.containsExactly(
new AppUsageObserver(
12,
ImmutableList.of("com.package1", "com.package2"),
123L,
TimeUnit.MINUTES,
pendingIntent1));
} |
<<<<<<<
import android.database.sqlite.SQLiteStatement;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
=======
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
>>>>>>>
import android.database.sqlite.SQLiteStatement;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
<<<<<<<
=======
/**
* Reflection helper methods.
*/
public static class Reflection {
public static <T> T newInstanceOf(Class<T> clazz) {
return Robolectric.newInstanceOf(clazz);
}
public static Object newInstanceOf(String className) {
return Robolectric.newInstanceOf(className);
}
public static void setFinalStaticField(Class classWhichContainsField, String fieldName, Object newValue) {
try {
Field field = classWhichContainsField.getField(fieldName);
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, newValue);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
>>>>>>>
/**
* Reflection helper methods.
*/
public static class Reflection {
public static <T> T newInstanceOf(Class<T> clazz) {
return Robolectric.newInstanceOf(clazz);
}
public static Object newInstanceOf(String className) {
return Robolectric.newInstanceOf(className);
}
public static void setFinalStaticField(Class classWhichContainsField, String fieldName, Object newValue) {
try {
Field field = classWhichContainsField.getField(fieldName);
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, newValue);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
} |
<<<<<<<
import android.view.animation.LayoutAnimationController;
=======
>>>>>>>
import android.view.animation.LayoutAnimationController;
<<<<<<<
private AnimationListener animListener;
private LayoutAnimationController layoutAnim;
private boolean disallowInterceptTouchEvent = false;
=======
private AnimationListener animListener;
>>>>>>>
private AnimationListener animListener;
private LayoutAnimationController layoutAnim;
private boolean disallowInterceptTouchEvent = false;
<<<<<<<
((ViewGroup) realView).addView(child, -1);
=======
((ViewGroup) realView).addView(child, -1);
addedChild(child);
>>>>>>>
((ViewGroup) realView).addView(child, -1);
<<<<<<<
((ViewGroup) realView).addView(child, -1, params);
=======
((ViewGroup) realView).addView(child, -1);
addedChild(child);
>>>>>>>
((ViewGroup) realView).addView(child, -1, params);
<<<<<<<
child.setLayoutParams(params);
((ViewGroup) realView).addView(child, index);
=======
((ViewGroup) realView).addView(child, index);
addedChild(child);
}
@Implementation
public void removeView(View child) {
// Android's ViewGroup ignores the child when it is null. Do the same here.
if (child == null) return;
shadowOf(child).parent = null;
children.remove(child);
removedChild(child);
>>>>>>>
child.setLayoutParams(params);
((ViewGroup) realView).addView(child, index);
}
@Implementation
public void removeView(View child) {
// Android's ViewGroup ignores the child when it is null. Do the same here.
if (child == null) return;
shadowOf(child).parent = null;
children.remove(child);
removedChild(child);
<<<<<<<
if( index >= children.size() ){ return null; }
return children.get(index);
=======
return isValidIndex(index) ? children.get(index) : null;
>>>>>>>
return isValidIndex(index) ? children.get(index) : null; |
<<<<<<<
public AlertDialog.Builder setMessage(int messageId) {
return setMessage(context.getResources().getString(messageId));
}
@Implementation
public AlertDialog.Builder setIcon(int iconId) {
return realBuilder;
}
@Implementation
=======
public AlertDialog.Builder setMessage(int messageId) {
setMessage(context.getResources().getString(messageId));
return realBuilder;
}
@Implementation
>>>>>>>
public AlertDialog.Builder setMessage(int messageId) {
setMessage(context.getResources().getString(messageId));
return realBuilder;
}
@Implementation
public AlertDialog.Builder setIcon(int iconId) {
return realBuilder;
}
@Implementation
<<<<<<<
public AlertDialog.Builder setPositiveButton(int buttonTextId, final DialogInterface.OnClickListener listener) {
return setPositiveButton(context.getResources().getString(buttonTextId), listener);
}
@Implementation
=======
public AlertDialog.Builder setPositiveButton(int positiveTextId, final DialogInterface.OnClickListener listener) {
return setPositiveButton(context.getResources().getText(positiveTextId), listener);
}
@Implementation
>>>>>>>
public AlertDialog.Builder setPositiveButton(int positiveTextId, final DialogInterface.OnClickListener listener) {
return setPositiveButton(context.getResources().getText(positiveTextId), listener);
}
@Implementation |
<<<<<<<
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
=======
import org.robolectric.internal.Implementation;
import org.robolectric.internal.Implements;
import org.robolectric.internal.RealObject;
import java.util.HashMap;
>>>>>>>
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import java.util.HashMap; |
<<<<<<<
import com.xtremelabs.robolectric.TestRunners;
=======
import android.view.View;
import android.view.ViewGroup;
import com.xtremelabs.robolectric.R;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
>>>>>>>
import android.view.View;
import android.view.ViewGroup;
import com.xtremelabs.robolectric.R;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.TestRunners;
<<<<<<<
@RunWith(TestRunners.WithDefaults.class)
=======
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
@RunWith(WithTestDefaultsRunner.class)
>>>>>>>
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
@RunWith(TestRunners.WithDefaults.class) |
<<<<<<<
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
=======
>>>>>>>
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
<<<<<<<
public boolean hasExtra(String name) {
return extras.containsKey(name);
}
@Implementation
=======
public ArrayList<Parcelable> getParcelableArrayListExtra(String key) {
return (ArrayList<Parcelable>) extras.get(key);
}
@Implementation
>>>>>>>
public ArrayList<Parcelable> getParcelableArrayListExtra(String key) {
return (ArrayList<Parcelable>) extras.get(key);
}
@Implementation
public boolean hasExtra(String name) {
return extras.containsKey(name);
}
@Implementation
<<<<<<<
public long getLongExtra(String name, long defaultValue) {
Long foundValue = (Long) extras.get(name);
return foundValue == null ? defaultValue : foundValue;
}
@Implementation
=======
public long getLongExtra(String name, long defaultValue) {
Long foundValue = (Long) extras.get(name);
return foundValue == null ? defaultValue : foundValue;
}
@Implementation
>>>>>>>
public long getLongExtra(String name, long defaultValue) {
Long foundValue = (Long) extras.get(name);
return foundValue == null ? defaultValue : foundValue;
}
@Implementation |
<<<<<<<
import static android.R.string.ok;
import static java.nio.charset.StandardCharsets.UTF_8;
=======
>>>>>>>
<<<<<<<
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
=======
>>>>>>>
import static org.junit.Assume.assumeTrue;
<<<<<<<
import static org.robolectric.R.bool.true_as_item;
import static org.robolectric.R.color.test_ARGB8;
import static org.robolectric.R.color.test_RGB8;
import static org.robolectric.R.dimen.test_px_dimen;
import static org.robolectric.R.fraction.half;
import static org.robolectric.R.integer.hex_int;
import static org.robolectric.R.integer.test_integer1;
import static org.robolectric.R.string.hello;
=======
>>>>>>>
<<<<<<<
import android.graphics.Color;
import android.os.Build.VERSION;
=======
>>>>>>>
<<<<<<<
import com.google.common.io.CharStreams;
import java.io.FileNotFoundException;
=======
>>>>>>>
import java.io.FileNotFoundException;
<<<<<<<
public void assertGetAssetsNotNull() {
AssetManager.getSystem();
assertNotNull(assetManager);
assetManager = RuntimeEnvironment.application.getAssets();
assertNotNull(assetManager);
assetManager = resources.getAssets();
assertNotNull(assetManager);
}
@Test
public void assetsPathListing() throws IOException {
assertThat(assetManager.list(""))
.contains(
"assetsHome.txt",
"docs",
"myFont.ttf");
assertThat(assetManager.list("docs"))
.contains("extra");
assertThat(assetManager.list("docs/extra"))
.contains("testing");
assertThat(assetManager.list("docs/extra/testing"))
.contains("hello.txt");
assertThat(assetManager.list("bogus-dir")).isEmpty();
}
@Test
public void open_shouldOpenFile() throws IOException {
final String contents =
CharStreams.toString(new InputStreamReader(assetManager.open("assetsHome.txt"), UTF_8));
assertThat(contents).isEqualTo("assetsHome!");
}
@Test
public void open_withAccessMode_shouldOpenFile() throws IOException {
final String contents = CharStreams.toString(
new InputStreamReader(assetManager.open("assetsHome.txt", AssetManager.ACCESS_BUFFER), UTF_8));
assertThat(contents).isEqualTo("assetsHome!");
}
@Test
public void openFd_shouldProvideFileDescriptorForAsset() throws Exception {
AssetFileDescriptor assetFileDescriptor = assetManager.openFd("assetsHome.txt");
assertThat(CharStreams.toString(new InputStreamReader(assetFileDescriptor.createInputStream(), UTF_8)))
.isEqualTo("assetsHome!");
assertThat(assetFileDescriptor.getLength()).isEqualTo(11);
}
@Test
public void openFd_shouldProvideFileDescriptorForDeflatedAsset() throws Exception {
assumeTrue(!isLegacyAssetManager());
expectedException.expect(FileNotFoundException.class);
expectedException.expectMessage("This file can not be opened as a file descriptor; it is probably compressed");
assetManager.openFd("deflatedAsset.xml");
}
@Test
=======
>>>>>>>
public void openFd_shouldProvideFileDescriptorForDeflatedAsset() throws Exception {
assumeTrue(!isLegacyAssetManager());
expectedException.expect(FileNotFoundException.class);
expectedException.expectMessage("This file can not be opened as a file descriptor; it is probably compressed");
assetManager.openFd("deflatedAsset.xml");
}
@Test
<<<<<<<
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_Robolectric, false);
ShadowAssetManager shadowAssetManager = Shadow.extract(assetManager);
shadowAssetManager.attrsToTypedArray(resources,
Robolectric.buildAttributeSet().setStyleAttribute("?attr/styleNotSpecifiedInAnyTheme").build(),
new int[]{R.attr.string1}, 0, shadowOf(theme).getNativePtr(), 0);
}
@Test
public void getResourceIdentifier_shouldReturnValueFromRClass() throws Exception {
assertThat(resources.getIdentifier("id_declared_in_item_tag", "id", "org.robolectric"))
.isEqualTo(R.id.id_declared_in_item_tag);
assertThat(resources.getIdentifier("id/id_declared_in_item_tag", null, "org.robolectric"))
.isEqualTo(R.id.id_declared_in_item_tag);
assertThat(resources.getIdentifier("org.robolectric:id_declared_in_item_tag", "id", null))
.isEqualTo(R.id.id_declared_in_item_tag);
assertThat(resources.getIdentifier("org.robolectric:id/id_declared_in_item_tag", "other", "other"))
.isEqualTo(R.id.id_declared_in_item_tag);
}
@Test
public void testGetResourceNames() throws Exception {
assertThat(resources.getResourceEntryName(R.layout.activity_main)).isEqualTo("activity_main");
assertThat(resources.getResourceTypeName(R.layout.activity_main)).isEqualTo("layout");
assertThat(resources.getResourcePackageName(R.layout.activity_main)).isEqualTo("org.robolectric");
assertThat(resources.getResourceName(R.layout.activity_main)).isEqualTo("org.robolectric:layout/activity_main");
}
@Test
public void whenPackageIsUnknown_getResourceIdentifier_shouldReturnZero() throws Exception {
assertThat(resources.getIdentifier("whatever", "id", "some.unknown.package"))
.isEqualTo(0);
assertThat(resources.getIdentifier("id/whatever", null, "some.unknown.package"))
.isEqualTo(0);
assertThat(resources.getIdentifier("some.unknown.package:whatever", "id", null))
.isEqualTo(0);
assertThat(resources.getIdentifier("some.unknown.package:id/whatever", "other", "other"))
.isEqualTo(0);
assertThat(resources.getIdentifier("whatever", "drawable", "some.unknown.package"))
.isEqualTo(0);
assertThat(resources.getIdentifier("drawable/whatever", null, "some.unknown.package"))
.isEqualTo(0);
assertThat(resources.getIdentifier("some.unknown.package:whatever", "drawable", null))
.isEqualTo(0);
assertThat(resources.getIdentifier("some.unknown.package:id/whatever", "other", "other"))
.isEqualTo(0);
}
@Test @Ignore("currently ids are always automatically assigned a value; to fix this we'd need to check "
+ "layouts for +@id/___, which is expensive")
public void whenCalledForIdWithNameNotInRClassOrXml_getResourceIdentifier_shouldReturnZero() throws Exception {
assertThat(resources.getIdentifier("org.robolectric:id/idThatDoesntExistAnywhere", "other", "other"))
.isEqualTo(0);
}
@Test
public void whenIdIsAbsentInXmlButPresentInRClass_getResourceIdentifier_shouldReturnIdFromRClass_probablyBecauseItWasDeclaredInALayout() throws Exception {
assertThat(resources.getIdentifier("id_declared_in_layout", "id", "org.robolectric"))
.isEqualTo(R.id.id_declared_in_layout);
}
@Test
public void whenResourceIsAbsentInXml_getResourceIdentifier_shouldReturn0() throws Exception {
assertThat(resources.getIdentifier("fictitiousDrawable", "drawable", "org.robolectric"))
.isEqualTo(0);
}
@Test
public void whenResourceIsAbsentInXml_getResourceIdentifier_shouldReturnId() throws Exception {
assertThat(resources.getIdentifier("an_image", "drawable", "org.robolectric"))
.isEqualTo(R.drawable.an_image);
}
@Test
public void whenResourceIsXml_getResourceIdentifier_shouldReturnId() throws Exception {
assertThat(resources.getIdentifier("preferences", "xml", "org.robolectric"))
.isEqualTo(R.xml.preferences);
}
@Test
public void whenResourceIsRaw_getResourceIdentifier_shouldReturnId() throws Exception {
assertThat(resources.getIdentifier("raw_resource", "raw", "org.robolectric"))
.isEqualTo(R.raw.raw_resource);
}
@Test
public void getResourceValue_boolean() {
TypedValue outValue = new TypedValue();
resources.getValue(R.bool.false_bool_value, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.INT_BOOLEAN.code());
assertThat(outValue.data).isEqualTo(0);
outValue = new TypedValue();
resources.getValue(true_as_item, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.INT_BOOLEAN.code());
assertThat(outValue.data).isNotEqualTo(0);
}
@Test
public void getResourceValue_int() {
TypedValue outValue = new TypedValue();
resources.getValue(test_integer1, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.INT_DEC.code());
assertThat(outValue.data).isEqualTo(2000);
}
@Test
public void getResourceValue_intHex() {
TypedValue outValue = new TypedValue();
resources.getValue(hex_int, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.INT_HEX.code());
assertThat(outValue.data).isEqualTo(0xFFFF0000);
}
@Test
public void getResourceValue_fraction() {
TypedValue outValue = new TypedValue();
resources.getValue(half, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.FRACTION.code());
assertThat(outValue.getFraction(1, 1)).isEqualTo(0.5f);
}
@Test
public void getResourceValue_dimension() {
TypedValue outValue = new TypedValue();
resources.getValue(test_px_dimen, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.DIMENSION.code());
assertThat(outValue.getDimension(new DisplayMetrics())).isEqualTo(15);
}
@Test
public void getResourceValue_colorARGB8() {
TypedValue outValue = new TypedValue();
resources.getValue(test_ARGB8, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.INT_COLOR_ARGB8.code());
assertThat(Color.blue(outValue.data)).isEqualTo(2);
}
@Test
public void getResourceValue_colorRGB8() {
TypedValue outValue = new TypedValue();
resources.getValue(test_RGB8, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.INT_COLOR_RGB8.code());
assertThat(Color.blue(outValue.data)).isEqualTo(4);
}
@Test
public void getResourceValue_string() {
TypedValue outValue = new TypedValue();
resources.getValue(hello, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.STRING.code());
assertThat(outValue.string).isEqualTo("Hello");
}
@Test
public void getResourceValue_frameworkString() {
TypedValue outValue = new TypedValue();
resources.getValue(ok, outValue, false);
assertThat(outValue.type).isEqualTo(DataType.STRING.code());
assertThat(outValue.string).isEqualTo("OK");
}
@Test
public void getResourceValue_fromSystem() {
assumeTrue(!isLegacyAssetManager());
TypedValue outValue = new TypedValue();
ShadowArscAssetManager systemShadowAssetManager = shadowOf(AssetManager.getSystem());
assertThat(systemShadowAssetManager.getResourceValue(android.R.string.ok, 0, outValue, false)).isTrue();
assertThat(outValue.type).isEqualTo(DataType.STRING.code());
assertThat(outValue.string).isEqualTo("OK");
}
@Test
public void configuration_default() {
assumeTrue(!isLegacyAssetManager());
ShadowArscAssetManager shadowAssetManager = shadowOf(assetManager);
ResTable_config config = shadowAssetManager.getConfiguration();
if (VERSION.SDK_INT > 16) {
assertThat(config.density).isEqualTo(0);
} else {
assertThat(config.density).isEqualTo(160);
}
}
@Test
@Config(qualifiers = "hdpi")
public void configuration_density() {
assumeTrue(!isLegacyAssetManager());
ShadowArscAssetManager shadowAssetManager = shadowOf(assetManager);
ResTable_config config = shadowAssetManager.getConfiguration();
assertThat(config.density).isEqualTo(240);
}
///////////////////////////////
private static int countBytes(InputStream i) throws IOException {
int count = 0;
while (i.read() != -1) {
count++;
}
i.close();
return count;
}
=======
shadowOf(assetManager)
.attrsToTypedArray(
resources,
Robolectric.buildAttributeSet()
.setStyleAttribute("?attr/styleNotSpecifiedInAnyTheme")
.build(),
new int[] {R.attr.string1},
0,
shadowOf(theme).getNativePtr(),
0);
}
>>>>>>>
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_Robolectric, false);
legacyShadowOf(assetManager)
.attrsToTypedArray(
resources,
Robolectric.buildAttributeSet()
.setStyleAttribute("?attr/styleNotSpecifiedInAnyTheme")
.build(),
new int[] {R.attr.string1},
0,
shadowOf(theme).getNativePtr(),
0);
}
///////////////////////////////
private static int countBytes(InputStream i) throws IOException {
int count = 0;
while (i.read() != -1) {
count++;
}
i.close();
return count;
} |
<<<<<<<
public void testNew() {
TransactionResult res = new TransactionResult(valid, returns, logs, 0);
assertTrue(res.validate());
=======
public void testCode() {
for (TransactionResult.Code code : TransactionResult.Code.values()) {
if (code.name().startsWith("SUCCESS")) {
assertTrue(code.isSuccess());
assertFalse(code.isFailure());
assertTrue(code.isAccepted());
assertFalse(code.isRejected());
} else if (code.name().startsWith("FAILURE")) {
assertFalse(code.isSuccess());
assertTrue(code.isFailure());
assertTrue(code.isAccepted());
assertFalse(code.isRejected());
} else {
assertFalse(code.isSuccess());
assertFalse(code.isFailure());
assertFalse(code.isAccepted());
assertTrue(code.isRejected());
}
}
}
>>>>>>>
public void testCode() {
for (TransactionResult.Code code : TransactionResult.Code.values()) {
if (code.name().startsWith("SUCCESS")) {
assertTrue(code.isSuccess());
assertFalse(code.isFailure());
assertTrue(code.isAccepted());
assertFalse(code.isRejected());
} else if (code.name().startsWith("FAILURE")) {
assertFalse(code.isSuccess());
assertTrue(code.isFailure());
assertTrue(code.isAccepted());
assertFalse(code.isRejected());
} else {
assertFalse(code.isSuccess());
assertFalse(code.isFailure());
assertFalse(code.isAccepted());
assertTrue(code.isRejected());
}
}
}
<<<<<<<
TransactionResult res = new TransactionResult(valid, returns, logs, 0);
=======
TransactionResult res = new TransactionResult(TransactionResult.Code.SUCCESS, returns, logs);
>>>>>>>
TransactionResult res = new TransactionResult(TransactionResult.Code.SUCCESS, returns, logs, 0);
<<<<<<<
TransactionResult res = new TransactionResult(valid, returns, logs, 0);
=======
TransactionResult res = new TransactionResult(TransactionResult.Code.SUCCESS, returns, logs);
>>>>>>>
TransactionResult res = new TransactionResult(TransactionResult.Code.SUCCESS, returns, logs, 0); |
<<<<<<<
import android.content.res.XmlResourceParser;
import android.graphics.Color;
=======
import android.graphics.drawable.ColorDrawable;
>>>>>>>
import android.graphics.drawable.ColorDrawable;
<<<<<<<
import android.util.TypedValue;
import android.util.Xml;
=======
import android.view.View;
import android.widget.Button;
>>>>>>>
import android.util.Xml;
import android.view.View;
import android.widget.Button;
<<<<<<<
@Test
public void withEmptyTheme_returnsEmptyAttributes() throws Exception {
assertThat(resources.newTheme().obtainStyledAttributes(new int[] {R.attr.string1}).hasValue(0)).isFalse();
}
@Test public void shouldGetValuesFromAttributeReference() throws Exception {
Theme theme = resources.newTheme();
theme.applyStyle(R.style.StyleWithAttributeReference, false);
TypedValue value1 = new TypedValue();
TypedValue value2 = new TypedValue();
boolean resolved1 = theme.resolveAttribute(R.attr.anAttribute, value1, true);
boolean resolved2 = theme.resolveAttribute(R.attr.attributeReferencingAnAttribute, value2, true);
assertThat(resolved1).isTrue();
assertThat(resolved2).isTrue();
assertThat(value1.resourceId).isEqualTo(R.string.hello);
assertThat(value2.resourceId).isEqualTo(R.string.hello);
assertThat(value1.coerceToString()).isEqualTo(value2.coerceToString());
}
@Test public void withResolveRefsFalse_shouldNotResolveResource() throws Exception {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.StyleWithReference, true);
TypedValue value = new TypedValue();
boolean resolved = theme.resolveAttribute(R.attr.stringReference, value, false);
assertThat(resolved).isTrue();
assertThat(value.type).isEqualTo(TypedValue.TYPE_REFERENCE);
assertThat(value.data).isEqualTo(R.string.hello);
}
@Test public void withResolveRefsTrue_shouldResolveResource() throws Exception {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.StyleWithReference, true);
TypedValue value = new TypedValue();
boolean resolved = theme.resolveAttribute(R.attr.stringReference, value, true);
assertThat(resolved).isTrue();
assertThat(value.type).isEqualTo(TypedValue.TYPE_STRING);
assertThat(value.resourceId).isEqualTo(R.string.hello);
assertThat(value.string).isEqualTo("Hello");
}
@Test public void failToResolveCircularReference() throws Exception {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.StyleWithCircularReference, true);
TypedValue value = new TypedValue();
boolean resolved = theme.resolveAttribute(R.attr.circularReference, value, false);
assertThat(resolved).isFalse();
}
@Test public void canResolveAttrReferenceToDifferentPackage() throws Exception {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_AnotherTheme, true);
TypedValue value = new TypedValue();
boolean resolved = theme.resolveAttribute(R.attr.styleReference, value, false);
assertThat(resolved).isTrue();
assertThat(value.type).isEqualTo(TypedValue.TYPE_REFERENCE);
assertThat(value.data).isEqualTo(R.style.Widget_AnotherTheme_Button);
}
@Test public void whenAThemeHasExplicitlyEmptyParentAttr_shouldHaveNoParent() throws Exception {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_Robolectric_EmptyParent, true);
assertThat(theme.obtainStyledAttributes(new int[] {R.attr.string1}).hasValue(0)).isFalse();
}
@Test public void applyStyle() throws Exception {
=======
@Test public void whenExplicitlySetOnActivity_afterSetContentView_activityGetsThemeFromActivityInManifest() throws Exception {
TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
activity.setTheme(R.style.Theme_Robolectric);
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xffff0000);
}
@Test public void whenExplicitlySetOnActivity_beforeSetContentView_activityUsesNewTheme() throws Exception {
ActivityController<TestActivityWithAnotherTheme> activityController = buildActivity(TestActivityWithAnotherTheme.class);
TestActivity activity = activityController.get();
activity.setTheme(R.style.Theme_Robolectric);
activityController.create();
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xff00ff00);
}
@Test public void whenSetOnActivityInManifest_activityGetsThemeFromActivityInManifest() throws Exception {
TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xffff0000);
}
@Test public void whenNotSetOnActivityInManifest_activityGetsThemeFromApplicationInManifest() throws Exception {
TestActivity activity = buildActivity(TestActivity.class).create().get();
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xff00ff00);
}
@Test public void shouldResolveReferencesThatStartWithAQuestionMark() throws Exception {
TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
Button theButton = (Button) activity.findViewById(R.id.button);
assertThat(theButton.getMinWidth()).isEqualTo(8);
assertThat(theButton.getMinHeight()).isEqualTo(8);
}
@Test public void shouldApplyStylesFromResourceReference() throws Exception {
Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_AnotherTheme, true);
TypedArray a = theme.obtainStyledAttributes(null, R.styleable.CustomView, 0, R.attr.animalStyle);
int animalStyleId = a.getResourceId(R.styleable.CustomView_animalStyle, 0);
assertThat(animalStyleId).isEqualTo(R.style.Gastropod);
assertThat(a.getFloat(R.styleable.CustomView_aspectRatio, 0.2f)).isEqualTo(1.69f);
}
@Test public void shouldApplyStylesFromAttributeReference() throws Exception {
Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_ThirdTheme, true);
TypedArray a = theme.obtainStyledAttributes(null, R.styleable.CustomView, 0, R.attr.animalStyle);
int animalStyleId = a.getResourceId(R.styleable.CustomView_animalStyle, 0);
assertThat(animalStyleId).isEqualTo(R.style.Gastropod);
assertThat(a.getFloat(R.styleable.CustomView_aspectRatio, 0.2f)).isEqualTo(1.69f);
}
@Test public void forStylesWithImplicitParents_shouldInheritValuesNotDefinedInChild() throws Exception {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_Robolectric_ImplicitChild, true);
assertThat(theme.obtainStyledAttributes(new int[] {R.attr.string1}).getString(0))
.isEqualTo("string 1 from Theme.Robolectric");
assertThat(theme.obtainStyledAttributes(new int[] {R.attr.string3}).getString(0))
.isEqualTo("string 3 from Theme.Robolectric.ImplicitChild");
}
@Test public void shouldApplyParentStylesFromAttrs() throws Exception {
>>>>>>>
@Test public void whenExplicitlySetOnActivity_afterSetContentView_activityGetsThemeFromActivityInManifest() throws Exception {
TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
activity.setTheme(R.style.Theme_Robolectric);
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xffff0000);
}
@Test public void whenExplicitlySetOnActivity_beforeSetContentView_activityUsesNewTheme() throws Exception {
ActivityController<TestActivityWithAnotherTheme> activityController = buildActivity(TestActivityWithAnotherTheme.class);
TestActivity activity = activityController.get();
activity.setTheme(R.style.Theme_Robolectric);
activityController.create();
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xff00ff00);
}
@Test public void whenSetOnActivityInManifest_activityGetsThemeFromActivityInManifest() throws Exception {
TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xffff0000);
}
@Test public void whenNotSetOnActivityInManifest_activityGetsThemeFromApplicationInManifest() throws Exception {
TestActivity activity = buildActivity(TestActivity.class).create().get();
Button theButton = (Button) activity.findViewById(R.id.button);
ColorDrawable background = (ColorDrawable) theButton.getBackground();
assertThat(background.getColor()).isEqualTo(0xff00ff00);
}
@Test public void shouldResolveReferencesThatStartWithAQuestionMark() throws Exception {
TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
Button theButton = (Button) activity.findViewById(R.id.button);
assertThat(theButton.getMinWidth()).isEqualTo(8);
assertThat(theButton.getMinHeight()).isEqualTo(8);
}
@Test public void shouldApplyStylesFromResourceReference() throws Exception {
Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_AnotherTheme, true);
TypedArray a = theme.obtainStyledAttributes(null, R.styleable.CustomView, 0, R.attr.animalStyle);
int animalStyleId = a.getResourceId(R.styleable.CustomView_animalStyle, 0);
assertThat(animalStyleId).isEqualTo(R.style.Gastropod);
assertThat(a.getFloat(R.styleable.CustomView_aspectRatio, 0.2f)).isEqualTo(1.69f);
}
@Test public void shouldApplyStylesFromAttributeReference() throws Exception {
Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_ThirdTheme, true);
TypedArray a = theme.obtainStyledAttributes(null, R.styleable.CustomView, 0, R.attr.animalStyle);
int animalStyleId = a.getResourceId(R.styleable.CustomView_animalStyle, 0);
assertThat(animalStyleId).isEqualTo(R.style.Gastropod);
assertThat(a.getFloat(R.styleable.CustomView_aspectRatio, 0.2f)).isEqualTo(1.69f);
}
@Test public void forStylesWithImplicitParents_shouldInheritValuesNotDefinedInChild() throws Exception {
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_Robolectric_EmptyParent, true);
assertThat(theme.obtainStyledAttributes(new int[] {R.attr.string1}).hasValue(0)).isFalse();
}
@Test public void shouldApplyParentStylesFromAttrs() throws Exception {
<<<<<<<
public void setTo_stylesShouldBeApplyableAcrossResources() throws Exception {
Resources.Theme themeFromSystem = Resources.getSystem().newTheme();
themeFromSystem.applyStyle(android.R.style.Theme_Light, true);
Resources.Theme themeFromApp = RuntimeEnvironment.application.getResources().newTheme();
themeFromApp.applyStyle(android.R.style.Theme, true);
// themeFromSystem is Theme_Light, which has a white background...
assertThat(themeFromSystem.obtainStyledAttributes(new int[]{android.R.attr.colorBackground}).getColor(0, 123))
.isEqualTo(Color.WHITE);
// themeFromApp is Theme, which has a black background...
assertThat(themeFromApp.obtainStyledAttributes(new int[]{android.R.attr.colorBackground}).getColor(0, 123))
.isEqualTo(Color.BLACK);
themeFromApp.setTo(themeFromSystem);
// themeFromApp now has style values from themeFromSystem, so now it has a black background...
assertThat(themeFromApp.obtainStyledAttributes(new int[]{android.R.attr.colorBackground}).getColor(0, 123))
.isEqualTo(Color.WHITE);
}
@Test
public void styleResolutionShouldIgnoreThemes() throws Exception {
Resources.Theme themeFromSystem = resources.newTheme();
themeFromSystem.applyStyle(android.R.style.Theme_DeviceDefault, true);
themeFromSystem.applyStyle(R.style.ThemeWithSelfReferencingTextAttr, true);
assertThat(themeFromSystem.obtainStyledAttributes(new int[]{android.R.attr.textAppearance})
.getResourceId(0, 0)).isEqualTo(0);
}
@Test
=======
>>>>>>>
<<<<<<<
@Test public void obtainStyledAttributes_shouldFindAttributeInDefaultStyleBeforeTheme() throws Exception {
Theme theme = resources.newTheme();
theme.applyStyle(R.style.StyleB, false); // string1 is also defined in StyleB but default style gets precedence over themes
TypedArray typedArray = theme.obtainStyledAttributes(R.style.StyleA, new int[]{R.attr.string1});
assertThat(typedArray.getString(0)).isEqualTo("string 1 from style A");
}
@Test public void shouldApplyFromStyleAttributes() throws Exception {
// TODO: Instead of using activity create a AttributeSet with a style attribute to keep the test more focused.
// TestWithStyleAttrActivity activity = buildActivity(TestWithStyleAttrActivity.class).create().get();
// View button = activity.findViewById(R.id.button);
// assertThat(button.getLayoutParams().width).isEqualTo(42); // comes via style attr
=======
@Test public void shouldApplyFromStyleAttribute() throws Exception {
TestWithStyleAttrActivity activity = buildActivity(TestWithStyleAttrActivity.class).create().get();
View button = activity.findViewById(R.id.button);
assertThat(button.getLayoutParams().width).isEqualTo(42); // comes via style attr
>>>>>>>
public static class TestActivityWithAnotherTheme extends TestActivity {
}
@Test public void shouldApplyFromStyleAttribute() throws Exception {
TestWithStyleAttrActivity activity = buildActivity(TestWithStyleAttrActivity.class).create().get();
View button = activity.findViewById(R.id.button);
assertThat(button.getLayoutParams().width).isEqualTo(42); // comes via style attr |
<<<<<<<
public boolean hasExtra(String name) {
return extras.containsKey(name);
=======
public void putExtra(String key, byte[] value) {
extras.put(key, value);
}
public String getStringExtra(String name) {
return (String) extras.get(name);
}
public Parcelable getParcelableExtra(String name) {
return (Parcelable) extras.get(name);
>>>>>>>
public boolean hasExtra(String name) {
return extras.containsKey(name);
}
public void putExtra(String key, byte[] value) {
extras.put(key, value);
}
public String getStringExtra(String name) {
return (String) extras.get(name);
}
public Parcelable getParcelableExtra(String name) {
return (Parcelable) extras.get(name);
<<<<<<<
public Serializable getSerializableExtra(String name) {
return (Serializable) extras.get(name);
}
public Parcelable getParcelableExtra(String name) {
return (Parcelable) extras.get(name);
}
private void verifySerializable (Serializable serializable) {
try {
ObjectOutputStream output = new ObjectOutputStream(new ByteArrayOutputStream());
output.writeObject(serializable);
output.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
=======
public byte[] getByteArrayExtra(String name) {
return (byte[]) extras.get(name);
}
public boolean realIntentEquals(FakeIntent o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (action != null ? !action.equals(o.action) : o.action != null) return false;
if (componentClass != null ? !componentClass.equals(o.componentClass) : o.componentClass != null)
return false;
if (data != null ? !data.equals(o.data) : o.data != null) return false;
if (extras != null ? !extras.equals(o.extras) : o.extras != null) return false;
return true;
}
>>>>>>>
public byte[] getByteArrayExtra(String name) {
return (byte[]) extras.get(name);
}
public Serializable getSerializableExtra(String name) {
return (Serializable) extras.get(name);
}
public boolean realIntentEquals(FakeIntent o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (action != null ? !action.equals(o.action) : o.action != null) return false;
if (componentClass != null ? !componentClass.equals(o.componentClass) : o.componentClass != null)
return false;
if (data != null ? !data.equals(o.data) : o.data != null) return false;
if (extras != null ? !extras.equals(o.extras) : o.extras != null) return false;
return true;
}
private void verifySerializable (Serializable serializable) {
try {
ObjectOutputStream output = new ObjectOutputStream(new ByteArrayOutputStream());
output.writeObject(serializable);
output.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
} |
<<<<<<<
import java.util.*;
import java.util.Map.Entry;
=======
>>>>>>>
<<<<<<<
import android.graphics.drawable.Drawable;
=======
>>>>>>>
import android.graphics.drawable.Drawable;
<<<<<<<
public void addResolveInfoForIntent(Intent intent, ResolveInfo info) {
List<ResolveInfo> l = resolveList.get(intent);
if (l == null) {
l = new ArrayList<ResolveInfo>();
resolveList.put(intent, l);
}
l.add(info);
}
@Override
public Drawable getActivityIcon(Intent intent) {
return drawableList.get(intent.getComponent());
}
@Override
public Drawable getActivityIcon(ComponentName componentName) {
return drawableList.get(componentName);
}
public void addActivityIcon( ComponentName component, Drawable d ) {
drawableList.put( component, d);
}
public void addActivityIcon( Intent intent, Drawable d ) {
drawableList.put( intent.getComponent(), d);
}
@Override
=======
public void setSystemFeature(String name, boolean value) {
systemFeatures.put(name, value);
}
@Override public boolean hasSystemFeature(String name) {
return systemFeatures.containsKey(name) ? systemFeatures.get(name) : false;
}
@Override
>>>>>>>
public void addResolveInfoForIntent(Intent intent, ResolveInfo info) {
List<ResolveInfo> l = resolveList.get(intent);
if (l == null) {
l = new ArrayList<ResolveInfo>();
resolveList.put(intent, l);
}
l.add(info);
}
@Override
public Drawable getActivityIcon(Intent intent) {
return drawableList.get(intent.getComponent());
}
@Override
public Drawable getActivityIcon(ComponentName componentName) {
return drawableList.get(componentName);
}
public void addActivityIcon( ComponentName component, Drawable d ) {
drawableList.put( component, d);
}
public void addActivityIcon( Intent intent, Drawable d ) {
drawableList.put( intent.getComponent(), d);
}
@Override |
<<<<<<<
import org.semux.gui.SwingUtil;
=======
import org.semux.gui.MessagesUtil;
>>>>>>>
import org.semux.gui.SwingUtil;
import org.semux.gui.MessagesUtil; |
<<<<<<<
import static android.os.Build.VERSION_CODES.M;
import static android.os.Build.VERSION_CODES.P;
=======
>>>>>>>
import static android.os.Build.VERSION_CODES.M;
<<<<<<<
// TODO(brettchabot): properly handle displayId
// @Implementation(minSdk = P)
// @HiddenApi
// protected static long nativeInitialize(
// long nativePtr,
// int deviceId,
// int source,
// int displayId,
// int action,
// int flags,
// int edgeFlags,
// int metaState,
// int buttonState,
// float xOffset,
// float yOffset,
// float xPrecision,
// float yPrecision,
// long downTimeNanos,
// long eventTimeNanos,
// int pointerCount,
// PointerProperties[] pointerIds,
// PointerCoords[] pointerCoords
// ) {
// return
// nativeInitialize(
// nativePtr,
// deviceId,
// source,
// action,
// flags,
// edgeFlags,
// metaState,
// buttonState,
// xOffset,
// yOffset,
// xPrecision,
// yPrecision,
// downTimeNanos,
// eventTimeNanos,
// pointerCount,
// pointerIds,
// pointerCoords);
// }
=======
>>>>>>> |
<<<<<<<
public class ShadowTypedArray {
private List<Object> values = new ArrayList<Object>();
=======
public class ShadowTypedArray implements UsesResources {
private Resources resources;
public void injectResources(Resources resources) {
this.resources = resources;
}
>>>>>>>
public class ShadowTypedArray implements UsesResources {
private Resources resources;
private List<Object> values = new ArrayList<Object>();
public void injectResources(Resources resources) {
this.resources = resources;
} |
<<<<<<<
byte[] prevHash = parent.getHash();
long timestamp = System.currentTimeMillis();
/*
* in case the previous block timestamp is drifted too munch, adjust this block
* timestamp to avoid invalid blocks (triggered by timestamp rule).
*
* See https://github.com/semuxproject/semux-core/issues/1
*/
timestamp = timestamp > parent.getTimestamp() ? timestamp : parent.getTimestamp() + 1;
=======
byte[] prevHash = chain.getBlockHeader(height - 1).getHash();
long timestamp = TimeUtil.currentTimeMillis();
>>>>>>>
byte[] prevHash = parent.getHash();
long timestamp = TimeUtil.currentTimeMillis();
/*
* in case the previous block timestamp is drifted too munch, adjust this block
* timestamp to avoid invalid blocks (triggered by timestamp rule).
*
* See https://github.com/semuxproject/semux-core/issues/1
*/
timestamp = timestamp > parent.getTimestamp() ? timestamp : parent.getTimestamp() + 1; |
<<<<<<<
public void __constructor__(Context baseContext) {
this.baseContext = baseContext;
}
=======
>>>>>>>
<<<<<<<
=======
@Implementation
public boolean isRestricted() {
return false;
}
/**
* Non-Android accessor that is used to grant permissions checked via
* {@link android.content.ContextWrapper#checkPermission(String, int, int)}
*
* @param permissionNames permission names that should be granted
*/
>>>>>>>
@Implementation
public boolean isRestricted() {
return false;
} |
<<<<<<<
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
=======
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
>>>>>>>
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull; |
<<<<<<<
public static ShadowAssetManager shadowOf(AssetManager instance) {
return (ShadowAssetManager) Robolectric.shadowOf_(instance);
}
=======
public static ShadowMediaRecorder shadowOf(MediaRecorder instance) {
return (ShadowMediaRecorder) shadowOf_(instance);
}
>>>>>>>
public static ShadowMediaRecorder shadowOf(MediaRecorder instance) {
return (ShadowMediaRecorder) shadowOf_(instance);
}
public static ShadowAssetManager shadowOf(AssetManager instance) {
return (ShadowAssetManager) Robolectric.shadowOf_(instance);
} |
<<<<<<<
private Method getMethod(Class<?> clazz, String methodName, Class<?>[] paramClasses) {
try {
return clazz.getMethod(methodName, paramClasses);
} catch (NoSuchMethodException e) {
try {
return clazz.getDeclaredMethod(methodName, paramClasses);
} catch (NoSuchMethodException e1) {
return null;
}
}
}
private Class<?> loadClass(String paramType, ClassLoader classLoader) {
=======
static Class<?> loadClass(String paramType, ClassLoader classLoader) {
>>>>>>>
private Method getMethod(Class<?> clazz, String methodName, Class<?>[] paramClasses) {
try {
return clazz.getMethod(methodName, paramClasses);
} catch (NoSuchMethodException e) {
try {
return clazz.getDeclaredMethod(methodName, paramClasses);
} catch (NoSuchMethodException e1) {
return null;
}
}
}
static Class<?> loadClass(String paramType, ClassLoader classLoader) { |
<<<<<<<
} catch (I18nException e) {
throw e;
=======
return true;
>>>>>>>
return true;
} catch (I18nException e) {
throw e; |
<<<<<<<
ShadowExpandableListView.class,
=======
ShadowFloatMath.class,
>>>>>>>
ShadowExpandableListView.class,
ShadowFloatMath.class,
<<<<<<<
ShadowMediaRecorder.class,
=======
ShadowMatrix.class,
ShadowMediaStore.ShadowImages.ShadowMedia.class,
>>>>>>>
ShadowMediaRecorder.class,
ShadowMatrix.class,
ShadowMediaStore.ShadowImages.ShadowMedia.class,
<<<<<<<
=======
Robolectric.backgroundScheduler = new Scheduler();
Robolectric.uiThreadScheduler = new Scheduler();
TestSharedPreferences.reset();
ShadowToast.reset();
ShadowAlertDialog.reset();
ShadowDialog.reset();
ShadowLooper.resetAll();
ShadowBitmapFactory.reset();
>>>>>>>
ShadowBitmapFactory.reset();
<<<<<<<
public static ShadowCamera shadowOf(Camera instance) {
return (ShadowCamera) shadowOf_(instance);
}
public static ShadowCameraParameters shadowOf(Camera.Parameters instance) {
return (ShadowCameraParameters) shadowOf_(instance);
}
public static ShadowMediaRecorder shadowOf(MediaRecorder instance) {
return (ShadowMediaRecorder) shadowOf_(instance);
}
public static ShadowAssetManager shadowOf(AssetManager instance) {
return (ShadowAssetManager) Robolectric.shadowOf_(instance);
}
=======
public static ShadowBitmap shadowOf(Bitmap other) {
return (ShadowBitmap) Robolectric.shadowOf_(other);
}
public static ShadowBluetoothAdapter shadowOf(BluetoothAdapter other) {
return (ShadowBluetoothAdapter) Robolectric.shadowOf_(other);
}
public static ShadowBluetoothDevice shadowOf(BluetoothDevice other) {
return (ShadowBluetoothDevice) Robolectric.shadowOf_(other);
}
public static ShadowMatrix shadowOf(Matrix other) {
return (ShadowMatrix) Robolectric.shadowOf_(other);
}
public static ShadowMotionEvent shadowOf(MotionEvent other) {
return (ShadowMotionEvent) Robolectric.shadowOf_(other);
}
>>>>>>>
public static ShadowCamera shadowOf(Camera instance) {
return (ShadowCamera) shadowOf_(instance);
}
public static ShadowCameraParameters shadowOf(Camera.Parameters instance) {
return (ShadowCameraParameters) shadowOf_(instance);
}
public static ShadowMediaRecorder shadowOf(MediaRecorder instance) {
return (ShadowMediaRecorder) shadowOf_(instance);
}
public static ShadowAssetManager shadowOf(AssetManager instance) {
return (ShadowAssetManager) Robolectric.shadowOf_(instance);
}
public static ShadowBitmap shadowOf(Bitmap other) {
return (ShadowBitmap) Robolectric.shadowOf_(other);
}
public static ShadowBluetoothAdapter shadowOf(BluetoothAdapter other) {
return (ShadowBluetoothAdapter) Robolectric.shadowOf_(other);
}
public static ShadowBluetoothDevice shadowOf(BluetoothDevice other) {
return (ShadowBluetoothDevice) Robolectric.shadowOf_(other);
}
public static ShadowMatrix shadowOf(Matrix other) {
return (ShadowMatrix) Robolectric.shadowOf_(other);
}
public static ShadowMotionEvent shadowOf(MotionEvent other) {
return (ShadowMotionEvent) Robolectric.shadowOf_(other);
} |
<<<<<<<
=======
import android.os.Bundle;
import android.view.View;
>>>>>>>
import android.os.Bundle;
import android.view.View;
<<<<<<<
=======
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
import static com.xtremelabs.robolectric.Robolectric.newInstanceOf;
import static com.xtremelabs.robolectric.util.TestUtil.newConfig;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.*;
>>>>>>>
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
import static com.xtremelabs.robolectric.Robolectric.newInstanceOf;
import static com.xtremelabs.robolectric.util.TestUtil.newConfig;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.*; |
<<<<<<<
import android.graphics.drawable.Drawable;
=======
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
>>>>>>>
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
<<<<<<<
import java.lang.reflect.Method;
=======
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
>>>>>>>
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
<<<<<<<
private Drawable backgroundDrawable;
private int measuredWidth;
private int measuredHeight;
=======
public Point scrollToCoordinates;
private boolean didRequestLayout;
private Drawable background;
private Animation animation;
>>>>>>>
private Drawable backgroundDrawable;
private int measuredWidth;
private int measuredHeight;
public Point scrollToCoordinates;
private boolean didRequestLayout;
private Drawable background;
private Animation animation;
<<<<<<<
applyOnClickAttribute();
}
public View.OnClickListener getOnClickListener() {
return onClickListener;
=======
applyTagAttribute();
applyOnClickAttribute();
>>>>>>>
applyTagAttribute();
applyOnClickAttribute();
}
public View.OnClickListener getOnClickListener() {
return onClickListener;
<<<<<<<
* @return the resource ID of this views background
*/
public int getBackgroundResourceId() {
return backgroundResourceId;
}
@Implementation
public void setBackgroundColor(int color) {
backgroundColor = color;
}
public int getBackgroundColor() {
return backgroundColor;
}
@Implementation
public void setBackgroundDrawable(Drawable drawable){
backgroundDrawable = drawable;
}
@Implementation
public Drawable getBackground() {
return backgroundDrawable;
}
/**
* Non-Android accessor.
*
=======
>>>>>>>
* @return the resource ID of this views background
*/
public int getBackgroundResourceId() {
return backgroundResourceId;
}
@Implementation
public void setBackgroundColor(int color) {
backgroundColor = color;
}
public int getBackgroundColor() {
return backgroundColor;
}
@Implementation
public void setBackgroundDrawable(Drawable drawable){
backgroundDrawable = drawable;
}
@Implementation
public Drawable getBackground() {
return backgroundDrawable;
}
/**
* Non-Android accessor.
*
<<<<<<<
private void applyOnClickAttribute() {
final String methodName = attributeSet.getAttributeValue("android", "onClick");
if (methodName != null) {
setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
try {
final Method method = context.getClass().getMethod(methodName, View.class);
method.invoke(context, view);
} catch (Exception ex) {
throw new RuntimeException("failed to invoke onClick method " + methodName, ex);
}
}
});
}
}
=======
private void applyOnClickAttribute() {
final String handlerName = attributeSet.getAttributeValue("android",
"onClick");
if (handlerName == null) {
return;
}
/* good part of following code has been directly copied from original
* android source */
setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Method mHandler;
try {
mHandler = getContext().getClass().getMethod(handlerName,
View.class);
} catch (NoSuchMethodException e) {
int id = getId();
String idText = id == View.NO_ID ? "" : " with id '"
+ shadowOf(context).getResourceLoader()
.getNameForId(id) + "'";
throw new IllegalStateException("Could not find a method " +
handlerName + "(View) in the activity "
+ getContext().getClass() + " for onClick handler"
+ " on view " + realView.getClass() + idText, e);
}
try {
mHandler.invoke(getContext(), realView);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Could not execute non "
+ "public method of the activity", e);
} catch (InvocationTargetException e) {
throw new IllegalStateException("Could not execute "
+ "method of the activity", e);
}
}
});
}
>>>>>>>
private void applyOnClickAttribute() {
final String handlerName = attributeSet.getAttributeValue("android",
"onClick");
if (handlerName == null) {
return;
}
/* good part of following code has been directly copied from original
* android source */
setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Method mHandler;
try {
mHandler = getContext().getClass().getMethod(handlerName,
View.class);
} catch (NoSuchMethodException e) {
int id = getId();
String idText = id == View.NO_ID ? "" : " with id '"
+ shadowOf(context).getResourceLoader()
.getNameForId(id) + "'";
throw new IllegalStateException("Could not find a method " +
handlerName + "(View) in the activity "
+ getContext().getClass() + " for onClick handler"
+ " on view " + realView.getClass() + idText, e);
}
try {
mHandler.invoke(getContext(), realView);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Could not execute non "
+ "public method of the activity", e);
} catch (InvocationTargetException e) {
throw new IllegalStateException("Could not execute "
+ "method of the activity", e);
}
}
});
} |
<<<<<<<
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.isSuccess());
=======
TransactionResult result = exec.execute(tx, as.track(), ds.track());
assertFalse(result.getCode().isSuccess());
>>>>>>>
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.getCode().isSuccess());
<<<<<<<
result = exec.execute(tx, as.track(), ds.track(), bh);
assertTrue(result.isSuccess());
=======
result = exec.execute(tx, as.track(), ds.track());
assertTrue(result.getCode().isSuccess());
>>>>>>>
result = exec.execute(tx, as.track(), ds.track(), bh);
assertTrue(result.getCode().isSuccess());
<<<<<<<
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.isSuccess());
=======
result = executeAndCommit(exec, tx, as.track(), ds.track());
assertTrue(result.getCode().isSuccess());
>>>>>>>
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.getCode().isSuccess());
<<<<<<<
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.isSuccess());
=======
TransactionResult result = exec.execute(tx, as.track(), ds.track());
assertFalse(result.getCode().isSuccess());
>>>>>>>
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.getCode().isSuccess());
<<<<<<<
result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.isSuccess());
=======
result = exec.execute(tx, as.track(), ds.track());
assertFalse(result.getCode().isSuccess());
>>>>>>>
result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.getCode().isSuccess());
<<<<<<<
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.isSuccess());
=======
result = executeAndCommit(exec, tx, as.track(), ds.track());
assertTrue(result.getCode().isSuccess());
>>>>>>>
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.getCode().isSuccess());
<<<<<<<
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.isSuccess());
=======
TransactionResult result = exec.execute(tx, as.track(), ds.track());
assertFalse(result.getCode().isSuccess());
>>>>>>>
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.getCode().isSuccess());
<<<<<<<
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.isSuccess());
=======
result = executeAndCommit(exec, tx, as.track(), ds.track());
assertTrue(result.getCode().isSuccess());
>>>>>>>
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.getCode().isSuccess());
<<<<<<<
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.isSuccess());
assertEquals(INSUFFICIENT_LOCKED, result.error);
=======
TransactionResult result = exec.execute(tx, as.track(), ds.track());
assertFalse(result.getCode().isSuccess());
assertEquals(INSUFFICIENT_LOCKED, result.code);
>>>>>>>
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.getCode().isSuccess());
assertEquals(INSUFFICIENT_LOCKED, result.code);
<<<<<<<
result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.isSuccess());
assertEquals(INSUFFICIENT_LOCKED, result.error);
=======
result = exec.execute(tx, as.track(), ds.track());
assertFalse(result.getCode().isSuccess());
assertEquals(INSUFFICIENT_LOCKED, result.code);
>>>>>>>
result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.getCode().isSuccess());
assertEquals(INSUFFICIENT_LOCKED, result.code);
<<<<<<<
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.isSuccess());
=======
result = executeAndCommit(exec, tx, as.track(), ds.track());
assertTrue(result.getCode().isSuccess());
>>>>>>>
result = executeAndCommit(exec, tx, as.track(), ds.track(), bh);
assertTrue(result.getCode().isSuccess());
<<<<<<<
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.isSuccess());
assertEquals(INSUFFICIENT_AVAILABLE, result.error);
=======
TransactionResult result = exec.execute(tx, as.track(), ds.track());
assertFalse(result.getCode().isSuccess());
assertEquals(INSUFFICIENT_AVAILABLE, result.code);
>>>>>>>
TransactionResult result = exec.execute(tx, as.track(), ds.track(), bh);
assertFalse(result.getCode().isSuccess());
assertEquals(INSUFFICIENT_AVAILABLE, result.code); |
<<<<<<<
ShadowKeyEvent.class,
=======
ShadowKeyguardManager.class,
>>>>>>>
ShadowKeyEvent.class,
ShadowKeyguardManager.class,
<<<<<<<
ShadowTabActivity.class,
ShadowTabHost.class,
ShadowTabSpec.class,
=======
ShadowTabHost.class,
ShadowTabSpec.class,
ShadowTelephonyManager.class,
>>>>>>>
ShadowTabActivity.class,
ShadowTabHost.class,
ShadowTabSpec.class,
ShadowTelephonyManager.class, |
<<<<<<<
import android.widget.FrameLayout;
import com.xtremelabs.robolectric.*;
import com.xtremelabs.robolectric.shadows.testing.OnMethodTestActivity;
=======
import com.xtremelabs.robolectric.ApplicationResolver;
import com.xtremelabs.robolectric.R;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
import com.xtremelabs.robolectric.shadows.testing.OnMethodTestActivity;
>>>>>>>
import android.widget.FrameLayout;
import com.xtremelabs.robolectric.*;
import com.xtremelabs.robolectric.shadows.testing.OnMethodTestActivity;
<<<<<<<
public void shouldNotRegisterNullBroadcastReceiver() {
DialogLifeCycleActivity activity = new DialogLifeCycleActivity();
activity.registerReceiver(null, new IntentFilter());
activity.onDestroy();
}
@Test
=======
public void startActivity_shouldDelegateToStartActivityForResult() {
final Transcript transcript = new Transcript();
Activity activity = new Activity() {
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
transcript.add("onActivityResult called with requestCode " + requestCode + ", resultCode " + resultCode + ", intent data " + data.getData());
}
};
activity.startActivity(new Intent().setType("image/*"));
shadowOf(activity).receiveResult(new Intent().setType("image/*"), Activity.RESULT_OK,
new Intent().setData(Uri.parse("content:foo")));
transcript.assertEventsSoFar("onActivityResult called with requestCode -1, resultCode -1, intent data content:foo");
}
@Test
>>>>>>>
public void shouldNotRegisterNullBroadcastReceiver() {
DialogLifeCycleActivity activity = new DialogLifeCycleActivity();
activity.registerReceiver(null, new IntentFilter());
activity.onDestroy();
}
@Test
public void startActivity_shouldDelegateToStartActivityForResult() {
final Transcript transcript = new Transcript();
Activity activity = new Activity() {
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
transcript.add("onActivityResult called with requestCode " + requestCode + ", resultCode " + resultCode + ", intent data " + data.getData());
}
};
activity.startActivity(new Intent().setType("image/*"));
shadowOf(activity).receiveResult(new Intent().setType("image/*"), Activity.RESULT_OK,
new Intent().setData(Uri.parse("content:foo")));
transcript.assertEventsSoFar("onActivityResult called with requestCode -1, resultCode -1, intent data content:foo");
}
@Test |
<<<<<<<
import org.robolectric.shadows.LegacyManifestParser;
import org.robolectric.shadows.ShadowActivityThread;
=======
>>>>>>>
import org.robolectric.shadows.LegacyManifestParser;
import org.robolectric.shadows.ShadowActivityThread;
<<<<<<<
String qualifiers = Bootstrap.applyQualifiers(config.qualifiers(),
- sdkConfig.getApiLevel(), configuration, displayMetrics);
=======
Bootstrap.applyQualifiers(config.qualifiers(), sdkConfig.getApiLevel(), configuration,
displayMetrics);
>>>>>>>
Bootstrap.applyQualifiers(config.qualifiers(), sdkConfig.getApiLevel(), configuration,
displayMetrics);
<<<<<<<
ReflectionHelpers.setField(activityThread, "mInstrumentation", new RoboInstrumentation());
PackageParser.Package parsedPackage = null;
ApplicationInfo applicationInfo = null;
if (appManifest.getAndroidManifestFile() != null
&& appManifest.getAndroidManifestFile().exists()) {
if (Boolean.parseBoolean(System.getProperty("use_framework_manifest_parser", "false"))) {
parsedPackage = ShadowPackageParser.callParsePackage(appManifest.getAndroidManifestFile());
} else {
parsedPackage = LegacyManifestParser.createPackage(appManifest);
}
} else {
parsedPackage = new PackageParser.Package("org.robolectric.default");
parsedPackage.applicationInfo.targetSdkVersion = appManifest.getTargetSdkVersion();
}
applicationInfo = parsedPackage.applicationInfo;
// Support overriding the package name specified in the Manifest.
if (!Config.DEFAULT_PACKAGE_NAME.equals(config.packageName())) {
parsedPackage.packageName = config.packageName();
parsedPackage.applicationInfo.packageName = config.packageName();
}
// TempDirectory tempDirectory = RuntimeEnvironment.getTempDirectory();
// packageInfo.setVolumeUuid(tempDirectory.createIfNotExists(packageInfo.packageName +
// "-dataDir").toAbsolutePath().toString());
setUpPackageStorage(applicationInfo);
// Bit of a hack... Context.createPackageContext() is called before the application is created.
// It calls through
// to ActivityThread for the package which in turn calls the PackageManagerService directly.
// This works for now
// but it might be nicer to have ShadowPackageManager implementation move into the service as
// there is also lots of
// code in there that can be reusable, e.g: the XxxxIntentResolver code.
ShadowActivityThread.setApplicationInfo(applicationInfo);
Class<?> contextImplClass =
ReflectionHelpers.loadClass(
getClass().getClassLoader(), shadowsAdapter.getShadowContextImplClassName());
=======
RoboInstrumentation androidInstrumentation = new RoboInstrumentation();
ReflectionHelpers.setField(activityThread, "mInstrumentation", androidInstrumentation);
>>>>>>>
ReflectionHelpers.setField(activityThread, "mInstrumentation", new RoboInstrumentation());
PackageParser.Package parsedPackage = null;
ApplicationInfo applicationInfo = null;
if (appManifest.getAndroidManifestFile() != null
&& appManifest.getAndroidManifestFile().exists()) {
if (Boolean.parseBoolean(System.getProperty("use_framework_manifest_parser", "false"))) {
parsedPackage = ShadowPackageParser.callParsePackage(appManifest.getAndroidManifestFile());
} else {
parsedPackage = LegacyManifestParser.createPackage(appManifest);
}
} else {
parsedPackage = new PackageParser.Package("org.robolectric.default");
parsedPackage.applicationInfo.targetSdkVersion = appManifest.getTargetSdkVersion();
}
applicationInfo = parsedPackage.applicationInfo;
// Support overriding the package name specified in the Manifest.
if (!Config.DEFAULT_PACKAGE_NAME.equals(config.packageName())) {
parsedPackage.packageName = config.packageName();
parsedPackage.applicationInfo.packageName = config.packageName();
}
// TempDirectory tempDirectory = RuntimeEnvironment.getTempDirectory();
// packageInfo.setVolumeUuid(tempDirectory.createIfNotExists(packageInfo.packageName +
// "-dataDir").toAbsolutePath().toString());
setUpPackageStorage(applicationInfo);
// Bit of a hack... Context.createPackageContext() is called before the application is created.
// It calls through
// to ActivityThread for the package which in turn calls the PackageManagerService directly.
// This works for now
// but it might be nicer to have ShadowPackageManager implementation move into the service as
// there is also lots of
// code in there that can be reusable, e.g: the XxxxIntentResolver code.
ShadowActivityThread.setApplicationInfo(applicationInfo);
Class<?> contextImplClass =
ReflectionHelpers.loadClass(
getClass().getClassLoader(), shadowsAdapter.getShadowContextImplClassName());
RoboInstrumentation androidInstrumentation = new RoboInstrumentation();
ReflectionHelpers.setField(activityThread, "mInstrumentation", androidInstrumentation); |
<<<<<<<
* @param appWidgetId id of widget
* @param views views to update
=======
*
* @param appWidgetId
* @param views
>>>>>>>
*
* @param appWidgetId id of widget
* @param views views to update
<<<<<<<
* @param appWidgetProviderClass the app widget provider class
* @param widgetLayoutId id of the layout to inflate
=======
*
* @param appWidgetProviderClass
* @param widgetLayoutId
>>>>>>>
*
* @param appWidgetProviderClass the app widget provider class
* @param widgetLayoutId id of the layout to inflate
<<<<<<<
* @param appWidgetProviderClass the app widget provider class
* @param widgetLayoutId id of the layout to inflate
* @param howManyToCreate number of new widgets to create
=======
*
* @param appWidgetProviderClass
* @param widgetLayoutId
* @param howManyToCreate
>>>>>>>
*
* @param appWidgetProviderClass the app widget provider class
* @param widgetLayoutId id of the layout to inflate
* @param howManyToCreate number of new widgets to create |
<<<<<<<
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static android.os.Build.VERSION_CODES.KITKAT_WATCH;
import static android.os.Build.VERSION_CODES.LOLLIPOP;
import static org.robolectric.RuntimeEnvironment.castNativePtr;
import static org.robolectric.Shadows.shadowOf;
@Implements(value = AssetManager.class, hackyTerribleIgnore = true)
=======
@Implements(AssetManager.class)
>>>>>>>
@Implements(value = AssetManager.class, hackyTerribleIgnore = true) |
<<<<<<<
import android.text.*;
=======
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.TextWatcher;
>>>>>>>
import android.text.*;
<<<<<<<
private List<Integer> previousKeyCodes = new ArrayList<Integer>();
private List<KeyEvent> previousKeyEvents = new ArrayList<KeyEvent>();
private Layout layout;
=======
>>>>>>>
private List<Integer> previousKeyCodes = new ArrayList<Integer>();
private List<KeyEvent> previousKeyEvents = new ArrayList<KeyEvent>();
private Layout layout;
<<<<<<<
@Implementation(i18nSafe = false)
=======
@Implementation(i18nSafe=false)
public final void append(CharSequence text) {
setText(getText().toString() + text);
}
@Implementation(i18nSafe=false)
>>>>>>>
@Implementation(i18nSafe = false)
<<<<<<<
if (text == null) {
=======
sendBeforeTextChanged(text);
if (text == null) {
>>>>>>>
if (text == null) {
<<<<<<<
sendBeforeTextChanged(text);
CharSequence oldValue = this.text;
=======
CharSequence oldValue = this.text;
>>>>>>>
sendBeforeTextChanged(text);
CharSequence oldValue = this.text;
<<<<<<<
sendOnTextChanged(oldValue);
sendAfterTextChanged();
}
@Implementation
public final void append(CharSequence text) {
boolean isSelectStartAtEnd = selectionStart == this.text.length();
boolean isSelectEndAtEnd = selectionEnd == this.text.length();
CharSequence oldValue = this.text;
StringBuffer sb = new StringBuffer(this.text);
sb.append(text);
sendBeforeTextChanged(sb.toString());
this.text = sb.toString();
if (isSelectStartAtEnd) {
selectionStart = this.text.length();
}
if (isSelectEndAtEnd) {
selectionEnd = this.text.length();
}
=======
>>>>>>>
sendOnTextChanged(oldValue);
sendAfterTextChanged();
}
@Implementation
public final void append(CharSequence text) {
boolean isSelectStartAtEnd = selectionStart == this.text.length();
boolean isSelectEndAtEnd = selectionEnd == this.text.length();
CharSequence oldValue = this.text;
StringBuffer sb = new StringBuffer(this.text);
sb.append(text);
sendBeforeTextChanged(sb.toString());
this.text = sb.toString();
if (isSelectStartAtEnd) {
selectionStart = this.text.length();
}
if (isSelectEndAtEnd) {
selectionEnd = this.text.length();
}
<<<<<<<
sendBeforeTextChanged(text);
CharSequence oldValue = this.text;
=======
sendBeforeTextChanged(text);
CharSequence oldValue = this.text;
>>>>>>>
sendBeforeTextChanged(text);
CharSequence oldValue = this.text;
<<<<<<<
sendOnTextChanged(oldValue);
=======
sendOnTextChanged(oldValue);
>>>>>>>
sendOnTextChanged(oldValue);
<<<<<<<
@Implementation
public boolean onKeyUp(int keyCode, KeyEvent event) {
previousKeyCodes.add(keyCode);
previousKeyEvents.add(event);
if (onKeyListener != null) {
return onKeyListener.onKey(realView, keyCode, event);
} else {
return false;
}
}
public int getPreviousKeyCode(int index) {
return previousKeyCodes.get(index);
}
public KeyEvent getPreviousKeyEvent(int index) {
return previousKeyEvents.get(index);
}
=======
>>>>>>>
@Implementation
public boolean onKeyUp(int keyCode, KeyEvent event) {
previousKeyCodes.add(keyCode);
previousKeyEvents.add(event);
if (onKeyListener != null) {
return onKeyListener.onKey(realView, keyCode, event);
} else {
return false;
}
}
public int getPreviousKeyCode(int index) {
return previousKeyCodes.get(index);
}
public KeyEvent getPreviousKeyEvent(int index) {
return previousKeyEvents.get(index);
}
<<<<<<<
public CompoundDrawables getCompoundDrawablesImpl() {
=======
public CompoundDrawables getCompoundDrawablesImpl() {
>>>>>>>
public CompoundDrawables getCompoundDrawablesImpl() {
<<<<<<<
@Implementation
public void removeTextChangedListener(TextWatcher watcher) {
this.watchers.remove(watcher);
}
@Implementation
public TextPaint getPaint() {
return textPaint;
}
@Implementation
public Layout getLayout() {
return this.layout;
}
public void setSelection(int index) {
setSelection(index, index);
}
public void setSelection(int start, int end) {
selectionStart = start;
selectionEnd = end;
}
@Implementation
public int getSelectionStart() {
return selectionStart;
}
@Implementation
public int getSelectionEnd() {
return selectionEnd;
}
@Implementation
public void setFilters(InputFilter[] inputFilters) {
this.inputFilters = inputFilters;
}
@Implementation
public InputFilter[] getFilters() {
return this.inputFilters;
}
@Implementation
public boolean hasSelection() {
return selectionStart >= 0 && selectionEnd >= 0;
}
@Implementation
public boolean onTouchEvent(MotionEvent event) {
boolean superResult = super.onTouchEvent(event);
if (movementMethod != null) {
boolean handled = movementMethod.onTouchEvent(null, null, event);
if (handled) {
return true;
}
}
return superResult;
}
=======
>>>>>>>
@Implementation
public void removeTextChangedListener(TextWatcher watcher) {
this.watchers.remove(watcher);
}
@Implementation
public TextPaint getPaint() {
return textPaint;
}
@Implementation
public Layout getLayout() {
return this.layout;
}
public void setSelection(int index) {
setSelection(index, index);
}
public void setSelection(int start, int end) {
selectionStart = start;
selectionEnd = end;
}
@Implementation
public int getSelectionStart() {
return selectionStart;
}
@Implementation
public int getSelectionEnd() {
return selectionEnd;
}
@Implementation
public void setFilters(InputFilter[] inputFilters) {
this.inputFilters = inputFilters;
}
@Implementation
public InputFilter[] getFilters() {
return this.inputFilters;
}
@Implementation
public boolean hasSelection() {
return selectionStart >= 0 && selectionEnd >= 0;
}
@Implementation
public boolean onTouchEvent(MotionEvent event) {
boolean superResult = super.onTouchEvent(event);
if (movementMethod != null) {
boolean handled = movementMethod.onTouchEvent(null, null, event);
if (handled) {
return true;
}
}
return superResult;
}
<<<<<<<
=======
@Override
protected void dumpAttributes(PrintStream out) {
super.dumpAttributes(out);
CharSequence text = getText();
if (text != null && text.length() > 0) {
dumpAttribute(out, "text", text.toString());
}
}
public static class CompoundDrawables {
public int left;
public int top;
public int right;
public int bottom;
>>>>>>> |
<<<<<<<
=======
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
>>>>>>>
import static android.os.Build.VERSION_CODES.N_MR1;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.shadows.ShadowArscAssetManager.isLegacyAssetManager;
<<<<<<<
import android.util.DisplayMetrics;
import android.util.TypedValue;
import java.io.FileNotFoundException;
=======
import com.google.common.io.CharStreams;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
>>>>>>>
import android.util.DisplayMetrics;
import android.util.TypedValue;
import com.google.common.io.CharStreams;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
<<<<<<<
import org.robolectric.res.android.DataType;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.util.Strings;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import static android.os.Build.VERSION_CODES.N_MR1;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.in;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.shadows.ShadowArscAssetManager.isLegacyAssetManager;
=======
>>>>>>>
import org.robolectric.res.android.DataType;
import org.robolectric.shadow.api.Shadow;
<<<<<<<
if (!isLegacyAssetManager(assetManager)) return;
expectedException.expect(FileNotFoundException.class);
expectedException.expectMessage("./res/drawable/does_not_exist.png");
=======
expectedException.expect(IOException.class);
expectedException.expectMessage(
"Unable to find resource for ./res/drawable/does_not_exist.png");
>>>>>>>
if (!isLegacyAssetManager(assetManager)) return;
expectedException.expect(FileNotFoundException.class);
expectedException.expectMessage(
"./res/drawable/does_not_exist.png");
<<<<<<<
public void forSystemResources_unknownResourceIdsShouldReportPackagesSearched() throws IOException {
if (!isLegacyAssetManager(assetManager)) return;
=======
public void forSystemResources_unknownResourceIdsShouldReportPackagesSearched()
throws IOException {
>>>>>>>
public void forSystemResources_unknownResourceIdsShouldReportPackagesSearched()
throws IOException {
if (!isLegacyAssetManager(assetManager)) return;
<<<<<<<
// @Test
// public void whenStyleAttrResolutionFails_attrsToTypedArray_returnsNiceErrorMessage() throws Exception {
// expectedException.expect(RuntimeException.class);
// expectedException.expectMessage(
// "no value for org.robolectric:attr/styleNotSpecifiedInAnyTheme " +
// "in theme with applied styles: [Style org.robolectric:Theme_Robolectric (and parents)]");
//
// Resources.Theme theme = resources.newTheme();
// theme.applyStyle(R.style.Theme_Robolectric, false);
//
// shadowAssetManager.attrsToTypedArray(resources,
// Robolectric.buildAttributeSet().setStyleAttribute("?attr/styleNotSpecifiedInAnyTheme").build(),
// new int[]{R.attr.string1}, 0, shadowOf(theme).getNativePtr(), 0);
// }
=======
@Test
public void whenStyleAttrResolutionFails_attrsToTypedArray_returnsNiceErrorMessage()
throws Exception {
expectedException.expect(RuntimeException.class);
expectedException.expectMessage(
"no value for org.robolectric:attr/styleNotSpecifiedInAnyTheme " +
"in theme with applied styles: [Style org.robolectric:Theme_Robolectric (and parents)]");
Resources.Theme theme = resources.newTheme();
theme.applyStyle(R.style.Theme_Robolectric, false);
shadowOf(assetManager)
.attrsToTypedArray(
resources,
Robolectric.buildAttributeSet()
.setStyleAttribute("?attr/styleNotSpecifiedInAnyTheme")
.build(),
new int[] {R.attr.string1},
0,
shadowOf(theme).getNativePtr(),
0);
}
>>>>>>>
// @Test
// public void whenStyleAttrResolutionFails_attrsToTypedArray_returnsNiceErrorMessage() throws Exception {
// expectedException.expect(RuntimeException.class);
// expectedException.expectMessage(
// "no value for org.robolectric:attr/styleNotSpecifiedInAnyTheme " +
// "in theme with applied styles: [Style org.robolectric:Theme_Robolectric (and parents)]");
//
// Resources.Theme theme = resources.newTheme();
// theme.applyStyle(R.style.Theme_Robolectric, false);
//
// shadowAssetManager.attrsToTypedArray(resources,
// Robolectric.buildAttributeSet().setStyleAttribute("?attr/styleNotSpecifiedInAnyTheme").build(),
// new int[]{R.attr.string1}, 0, shadowOf(theme).getNativePtr(), 0);
// }
<<<<<<<
assertThat(
shadowAssetManager.getResourceIdentifier("fictitiousDrawable", "drawable", "org.robolectric"))
=======
assertThat(
shadowOf(assetManager)
.getResourceIdentifier("fictitiousDrawable", "drawable", "org.robolectric"))
>>>>>>>
assertThat(shadowAssetManager.getResourceIdentifier("fictitiousDrawable", "drawable", "org.robolectric"))
<<<<<<<
assertThat(shadowAssetManager.getResourceIdentifier("an_image", "drawable", "org.robolectric"))
=======
assertThat(
shadowOf(assetManager).getResourceIdentifier("an_image", "drawable", "org.robolectric"))
>>>>>>>
assertThat(shadowAssetManager.getResourceIdentifier("an_image", "drawable", "org.robolectric"))
<<<<<<<
assertThat(shadowAssetManager.getResourceIdentifier("preferences", "xml", "org.robolectric"))
=======
assertThat(
shadowOf(assetManager).getResourceIdentifier("preferences", "xml", "org.robolectric"))
>>>>>>>
assertThat(shadowAssetManager.getResourceIdentifier("preferences", "xml", "org.robolectric"))
<<<<<<<
assertThat(shadowAssetManager.getResourceIdentifier("raw_resource", "raw", "org.robolectric"))
=======
assertThat(
shadowOf(assetManager).getResourceIdentifier("raw_resource", "raw", "org.robolectric"))
>>>>>>>
assertThat(shadowAssetManager.getResourceIdentifier("raw_resource", "raw", "org.robolectric")) |
<<<<<<<
OperationParser.getRequestBody(apiOperation.requestBody(), classProduces, methodProduces, components).ifPresent(operation::setRequestBody);
=======
>>>>>>> |
<<<<<<<
Map<String, Example> exampleMap = new HashMap<>();
=======
Map<String, Example> exampleMap = new LinkedHashMap<>();
final Object exampleValue;
>>>>>>>
Map<String, Example> exampleMap = new LinkedHashMap<>(); |
<<<<<<<
=======
long timestamp = TimeUtil.currentTimeMillis();
>>>>>>> |
<<<<<<<
import org.ethereum.vm.DataWord;
import org.ethereum.vm.LogInfo;
=======
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bouncycastle.util.encoders.Hex;
>>>>>>>
import org.ethereum.vm.DataWord;
import org.ethereum.vm.LogInfo;
import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.util.encoders.Hex;
<<<<<<<
*
* @param success
=======
*
* @param code
>>>>>>>
*
*
* @param code
<<<<<<<
public TransactionResult(boolean success, byte[] output, List<LogInfo> logs, long gasUsed) {
=======
public TransactionResult(Code code, byte[] output, List<byte[]> logs) {
>>>>>>>
public TransactionResult(Code code, byte[] output, List<LogInfo> logs, long gasUsed) {
<<<<<<<
public Error getError() {
return error;
}
public void setError(Error error) {
this.error = error;
}
public Long getGasUsed() {
return gasUsed;
}
public void setGasUsed(long gasUsed) {
this.gasUsed = gasUsed;
}
=======
>>>>>>>
public Long getGasUsed() {
return gasUsed;
}
public void setGasUsed(long gasUsed) {
this.gasUsed = gasUsed;
}
<<<<<<<
return new TransactionResult(valid, returns, logs, gasUsed);
=======
return new TransactionResult(success ? Code.SUCCESS : Code.FAILURE, returns, logs);
>>>>>>>
return new TransactionResult(success ? Code.SUCCESS : Code.FAILURE, returns, logs, gasUsed);
<<<<<<<
return "TransactionResult [success=" + success + ", output=" + Arrays.toString(returns) + ", # logs="
+ logs.size() + ", gasUsed=" + gasUsed + "]";
=======
return "TransactionResult [code=" + code + ", returnData=" + Hex.toHexString(returnData) + ", # logs="
+ logs.size() + "]";
>>>>>>>
return "TransactionResult [code=" + code + ", returnData=" + Hex.toHexString(returnData) + ", # logs="
+ logs.size() + "]"; |
<<<<<<<
public interface IParent<T extends Number> extends IGrandparent<T> {
=======
@IndirectAnnotation
public interface IParent<T extends Number> {
>>>>>>>
@IndirectAnnotation
public interface IParent<T extends Number> extends IGrandparent<T> { |
<<<<<<<
this.coinbase.setText("Account #" + model.getCoinbase());
this.status.setText(model.isDelegate() ? "Delegate" : "Normal");
this.balance.setText(SwingUtil.formatDouble(model.getTotalBalance() / (double) Unit.SEM) + " SEM");
this.locked.setText(SwingUtil.formatDouble(model.getTotalLocked() / (double) Unit.SEM) + " SEM");
=======
this.coinbase.setText(MessagesUtil.get("AccountNum") + model.getCoinbase());
this.status.setText(model.isDelegate() ? MessagesUtil.get("Delegate") : MessagesUtil.get("Normal"));
this.balance.setText(String.format("%.3f SEM", model.getTotalBalance() / (double) Unit.SEM));
this.locked.setText(String.format("%.3f SEM", model.getTotalLocked() / (double) Unit.SEM));
>>>>>>>
this.coinbase.setText("Account #" + model.getCoinbase());
this.status.setText(model.isDelegate() ? MessagesUtil.get("Delegate") : MessagesUtil.get("Normal"));
this.balance.setText(SwingUtil.formatDouble(model.getTotalBalance() / (double) Unit.SEM) + " SEM");
this.locked.setText(SwingUtil.formatDouble(model.getTotalLocked() / (double) Unit.SEM) + " SEM"); |
<<<<<<<
private final PrecompiledContractContext context;
=======
private DelegateState delegateState;
>>>>>>>
private final DelegateState delegateState;
<<<<<<<
this.context = new PrecompiledContractContext() {
};
}
@Override
public PrecompiledContractContext getContext() {
return context;
=======
this.delegateState = delegateState;
}
@Override
public PrecompiledContractContext getContext() {
return null;
>>>>>>>
this.delegateState = delegateState; |
<<<<<<<
import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.util.Json;
=======
>>>>>>>
import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.util.Json;
<<<<<<<
final ParamWrapper<?> param = helper.getApiParam();
=======
final JavaType javaType = TypeFactory.defaultInstance().constructType(type);
final ApiParam param = helper.getApiParam();
>>>>>>>
final ParamWrapper<?> param = helper.getApiParam();
final JavaType javaType = TypeFactory.defaultInstance().constructType(type);
final ApiParam param = helper.getApiParam();
<<<<<<<
final String defaultValue = param.getDefaultValue();
if (param.isAllowMultiple() || isArray) {
=======
final String defaultValue = param.defaultValue();
if (p.getItems() != null || param.allowMultiple()) {
if (p.getItems() == null) {
// Convert to array
final Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<PropertyBuilder.PropertyId, Object>(PropertyBuilder.PropertyId.class);
args.put(PropertyBuilder.PropertyId.DEFAULT, p.getDefaultValue());
p.setDefaultValue(null);
args.put(PropertyBuilder.PropertyId.ENUM, p.getEnum());
p.setEnum(null);
args.put(PropertyBuilder.PropertyId.MINIMUM, p.getMinimum());
p.setMinimum(null);
args.put(PropertyBuilder.PropertyId.EXCLUSIVE_MINIMUM, p.isExclusiveMinimum());
p.setExclusiveMinimum(null);
args.put(PropertyBuilder.PropertyId.MAXIMUM, p.getMaximum());
p.setMaximum(null);
args.put(PropertyBuilder.PropertyId.EXCLUSIVE_MAXIMUM, p.isExclusiveMaximum());
p.setExclusiveMaximum(null);
Property items = PropertyBuilder.build(p.getType(), p.getFormat(), args);
p.type(ArrayProperty.TYPE).format(null).items(items);
}
>>>>>>>
final String defaultValue = param.defaultValue();
if (p.getItems() != null || param.allowMultiple()) {
if (p.getItems() == null) {
// Convert to array
final Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<PropertyBuilder.PropertyId, Object>(PropertyBuilder.PropertyId.class);
args.put(PropertyBuilder.PropertyId.DEFAULT, p.getDefaultValue());
p.setDefaultValue(null);
args.put(PropertyBuilder.PropertyId.ENUM, p.getEnum());
p.setEnum(null);
args.put(PropertyBuilder.PropertyId.MINIMUM, p.getMinimum());
p.setMinimum(null);
args.put(PropertyBuilder.PropertyId.EXCLUSIVE_MINIMUM, p.isExclusiveMinimum());
p.setExclusiveMinimum(null);
args.put(PropertyBuilder.PropertyId.MAXIMUM, p.getMaximum());
p.setMaximum(null);
args.put(PropertyBuilder.PropertyId.EXCLUSIVE_MAXIMUM, p.isExclusiveMaximum());
p.setExclusiveMaximum(null);
Property items = PropertyBuilder.build(p.getType(), p.getFormat(), args);
p.type(ArrayProperty.TYPE).format(null).items(items);
}
final String defaultValue = param.getDefaultValue();
if (param.isAllowMultiple() || isArray) { |
<<<<<<<
private Map<String, Object> vendorExtensions = new HashMap<String, Object>();
=======
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();
>>>>>>>
private Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>(); |
<<<<<<<
import java.math.BigDecimal;
=======
import java.lang.reflect.Array;
>>>>>>>
import java.math.BigDecimal;
import java.lang.reflect.Array;
<<<<<<<
if (NumberUtils.isNumber(schema.maximum())) {
String filteredMaximum = schema.maximum().replaceAll(COMMA, StringUtils.EMPTY);
schemaObject.setMaximum(new BigDecimal(filteredMaximum));
}
if (NumberUtils.isNumber(schema.minimum())) {
String filteredMinimum = schema.minimum().replaceAll(COMMA, StringUtils.EMPTY);
schemaObject.setMinimum(new BigDecimal(filteredMinimum));
}
ReaderUtils.getStringListFromStringArray(schema._enum()).ifPresent(schemaObject::setEnum);
=======
ReaderUtils.getStringListFromStringArray(schema.allowableValues()).ifPresent(schemaObject::setEnum);
>>>>>>>
if (NumberUtils.isNumber(schema.maximum())) {
String filteredMaximum = schema.maximum().replaceAll(COMMA, StringUtils.EMPTY);
schemaObject.setMaximum(new BigDecimal(filteredMaximum));
}
if (NumberUtils.isNumber(schema.minimum())) {
String filteredMinimum = schema.minimum().replaceAll(COMMA, StringUtils.EMPTY);
schemaObject.setMinimum(new BigDecimal(filteredMinimum));
}
ReaderUtils.getStringListFromStringArray(schema.allowableValues()).ifPresent(schemaObject::setEnum); |
<<<<<<<
=======
import io.swagger.oas.annotations.enums.Explode;
import io.swagger.oas.annotations.media.ArraySchema;
import io.swagger.oas.annotations.media.Content;
import io.swagger.oas.annotations.media.Schema;
import io.swagger.oas.annotations.parameters.Parameters;
>>>>>>> |
<<<<<<<
byte[] prevHash = getKernel().getBlockchain().getLatestBlock().getHash();
long timestamp = TimeUtil.currentTimeMillis();
=======
long timestamp = System.currentTimeMillis();
>>>>>>>
long timestamp = TimeUtil.currentTimeMillis(); |
<<<<<<<
import org.ethereum.vm.DataWord;
import org.ethereum.vm.LogInfo;
=======
import org.ethereum.vm.program.InternalTransaction;
>>>>>>>
import org.ethereum.vm.DataWord;
import org.ethereum.vm.LogInfo;
import org.ethereum.vm.program.InternalTransaction; |
<<<<<<<
public String getType() {
return type;
}
public String getFormat() {
return format;
}
=======
public Double getDecimalMin() {
return decimalMin;
}
public boolean isMinExclusive() {
return minExclusive;
}
public Integer getMinLength() {
return minLength;
}
public Integer getMaxLength() {
return maxLength;
}
public String getPattern() {
return pattern;
}
>>>>>>>
public String getType() {
return type;
}
public String getFormat() {
return format;
}
public Double getDecimalMin() {
return decimalMin;
}
public boolean isMinExclusive() {
return minExclusive;
}
public Integer getMinLength() {
return minLength;
}
public Integer getMaxLength() {
return maxLength;
}
public String getPattern() {
return pattern;
} |
<<<<<<<
=======
// fetch pending transactions
final List<PendingManager.PendingTransaction> pending = pendingMgr
.getPendingTransactions(config.maxBlockTransactionsSize());
final List<Transaction> pendingTxs = pending.stream()
.map(tx -> tx.transaction)
.collect(Collectors.toList());
final List<TransactionResult> pendingResults = pending.stream()
.map(tx -> tx.result)
.collect(Collectors.toList());
// compute roots
byte[] transactionsRoot = MerkleUtil.computeTransactionsRoot(pendingTxs);
byte[] resultsRoot = MerkleUtil.computeResultsRoot(pendingResults);
byte[] stateRoot = Bytes.EMPTY_HASH;
>>>>>>> |
<<<<<<<
public static ItemRadioCtrlCard ITEM_RADIO_CONTROL_CARD = new ItemRadioCtrlCard();
=======
public static ItemSwitchHammer ITEM_SWITCH_HAMMER = new ItemSwitchHammer();
>>>>>>>
public static ItemRadioCtrlCard ITEM_RADIO_CONTROL_CARD = new ItemRadioCtrlCard();
public static ItemSwitchHammer ITEM_SWITCH_HAMMER = new ItemSwitchHammer(); |
<<<<<<<
else if(sync.getInteger(HORN) == 0 && horn.isPlaying() && this.getDefinition().getHornSus()){
if (hornVolume > 0) {
=======
else if(this.getDataManager().get(HORN) == 0 && horn.isPlaying() && this.getDefinition().getHornSus()){
if (hornVolume > 0.5) {
>>>>>>>
else if(sync.getInteger(HORN) == 0 && horn.isPlaying() && this.getDefinition().getHornSus()){
if (hornVolume > 0.5) { |
<<<<<<<
public static ItemTrackExchanger ITEM_TRACK_EXCHANGER = new ItemTrackExchanger();
=======
public static void register() {
// loads static classes and ctrs
}
>>>>>>>
public static ItemTrackExchanger ITEM_TRACK_EXCHANGER = new ItemTrackExchanger();
public static void register() {
// loads static classes and ctrs
} |
<<<<<<<
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.function.Function;
import cam72cam.immersiverailroading.render.ExpireableList;
import cam72cam.immersiverailroading.render.OBJTextureSheet;
import cam72cam.immersiverailroading.tile.TileRailBase;
import cam72cam.immersiverailroading.util.BlockUtil;
import net.minecraft.nbt.NBTTagCompound;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GLContext;
import cam72cam.immersiverailroading.ConfigGraphics;
import cam72cam.immersiverailroading.ConfigSound;
import cam72cam.immersiverailroading.IRBlocks;
import cam72cam.immersiverailroading.IRItems;
import cam72cam.immersiverailroading.ImmersiveRailroading;
import cam72cam.immersiverailroading.blocks.BlockRailBase;
import cam72cam.immersiverailroading.entity.CarFreight;
import cam72cam.immersiverailroading.entity.EntityMoveableRollingStock;
import cam72cam.immersiverailroading.entity.FreightTank;
import cam72cam.immersiverailroading.entity.EntityRidableRollingStock;
import cam72cam.immersiverailroading.entity.EntityRollingStock;
import cam72cam.immersiverailroading.entity.EntitySmokeParticle;
import cam72cam.immersiverailroading.entity.LocomotiveSteam;
import cam72cam.immersiverailroading.entity.Tender;
import cam72cam.immersiverailroading.gui.CastingGUI;
import cam72cam.immersiverailroading.gui.FreightContainer;
import cam72cam.immersiverailroading.gui.FreightContainerGui;
import cam72cam.immersiverailroading.gui.PlateRollerGUI;
import cam72cam.immersiverailroading.gui.SteamHammerContainer;
import cam72cam.immersiverailroading.gui.SteamHammerContainerGui;
import cam72cam.immersiverailroading.gui.SteamLocomotiveContainer;
import cam72cam.immersiverailroading.gui.SteamLocomotiveContainerGui;
import cam72cam.immersiverailroading.gui.TankContainer;
import cam72cam.immersiverailroading.gui.TankContainerGui;
import cam72cam.immersiverailroading.gui.TenderContainer;
import cam72cam.immersiverailroading.gui.TenderContainerGui;
import cam72cam.immersiverailroading.gui.TrackGui;
=======
import cam72cam.immersiverailroading.*;
import cam72cam.immersiverailroading.entity.*;
import cam72cam.immersiverailroading.gui.*;
>>>>>>>
import cam72cam.immersiverailroading.ConfigGraphics;
import cam72cam.immersiverailroading.ConfigSound;
import cam72cam.immersiverailroading.IRBlocks;
import cam72cam.immersiverailroading.IRItems;
import cam72cam.immersiverailroading.ImmersiveRailroading;
import cam72cam.immersiverailroading.blocks.BlockRailBase;
import cam72cam.immersiverailroading.entity.CarFreight;
import cam72cam.immersiverailroading.entity.EntityMoveableRollingStock;
import cam72cam.immersiverailroading.entity.FreightTank;
import cam72cam.immersiverailroading.entity.EntityRidableRollingStock;
import cam72cam.immersiverailroading.entity.EntityRollingStock;
import cam72cam.immersiverailroading.entity.EntitySmokeParticle;
import cam72cam.immersiverailroading.entity.LocomotiveSteam;
import cam72cam.immersiverailroading.entity.Tender;
import cam72cam.immersiverailroading.gui.CastingGUI;
import cam72cam.immersiverailroading.gui.FreightContainer;
import cam72cam.immersiverailroading.gui.FreightContainerGui;
import cam72cam.immersiverailroading.gui.PlateRollerGUI;
import cam72cam.immersiverailroading.gui.SteamHammerContainer;
import cam72cam.immersiverailroading.gui.SteamHammerContainerGui;
import cam72cam.immersiverailroading.gui.SteamLocomotiveContainer;
import cam72cam.immersiverailroading.gui.SteamLocomotiveContainerGui;
import cam72cam.immersiverailroading.gui.TankContainer;
import cam72cam.immersiverailroading.gui.TankContainerGui;
import cam72cam.immersiverailroading.gui.TenderContainer;
import cam72cam.immersiverailroading.gui.TenderContainerGui;
import cam72cam.immersiverailroading.gui.TrackGui;
<<<<<<<
ModelLoader.setCustomModelResourceLocation(IRItems.ITEM_RADIO_CONTROL_CARD, 0,
new ModelResourceLocation(IRItems.ITEM_RADIO_CONTROL_CARD.getRegistryName(), ""));
=======
ModelLoader.setCustomModelResourceLocation(IRItems.ITEM_SWITCH_HAMMER, 0,
new ModelResourceLocation("minecraft:stick", ""));
>>>>>>>
ModelLoader.setCustomModelResourceLocation(IRItems.ITEM_RADIO_CONTROL_CARD, 0,
new ModelResourceLocation(IRItems.ITEM_RADIO_CONTROL_CARD.getRegistryName(), ""));
ModelLoader.setCustomModelResourceLocation(IRItems.ITEM_SWITCH_HAMMER, 0,
new ModelResourceLocation("minecraft:stick", "")); |
<<<<<<<
this.horn = ImmersiveRailroading.proxy.newSound(this.getDefinition().horn, this.getDefinition().getHornSus(), 100, gauge);
this.idle = ImmersiveRailroading.proxy.newSound(this.getDefinition().idle, true, 80, gauge);
this.bell = ImmersiveRailroading.proxy.newSound(this.getDefinition().bell, true, 80, gauge);
=======
this.horn = ImmersiveRailroading.proxy.newSound(this.getDefinition().horn, false, 100, this.soundGauge());
this.idle = ImmersiveRailroading.proxy.newSound(this.getDefinition().idle, true, 80, this.soundGauge());
>>>>>>>
this.horn = ImmersiveRailroading.proxy.newSound(this.getDefinition().horn, this.getDefinition().getHornSus(), 100, this.soundGauge());
this.idle = ImmersiveRailroading.proxy.newSound(this.getDefinition().idle, true, 80, this.soundGauge());
this.bell = ImmersiveRailroading.proxy.newSound(this.getDefinition().bell, true, 80, this.soundGauge()); |
<<<<<<<
public void cycleSwitchForced() {
=======
public BlockPos getParentReplaced() {
if (this.replaced == null) {
return null;
}
if (!this.replaced.hasKey("parent")) {
return null;
}
return BlockPos.fromLong(this.replaced.getLong("parent")).add(pos);
}
public void toggleSwitchForced() {
>>>>>>>
public BlockPos getParentReplaced() {
if (this.replaced == null) {
return null;
}
if (!this.replaced.hasKey("parent")) {
return null;
}
return BlockPos.fromLong(this.replaced.getLong("parent")).add(pos);
}
public void cycleSwitchForced() { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.