This repository has been archived by the owner on Jul 24, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix line endings on all affected files in repository (#121)
... ONCE AND FOR ALL
- Loading branch information
Showing
7 changed files
with
469 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# always use unix line endings | ||
* text eol=lf | ||
*.jar binary -diff | ||
*.png binary -diff |
84 changes: 42 additions & 42 deletions
84
api/javatests/org/openyolo/api/internal/ActivityResultTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
package org.openyolo.api.internal; | ||
|
||
import android.content.Intent; | ||
import android.os.Parcel; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.openyolo.protocol.CredentialDeleteResult; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
/** | ||
* Units tests for {@link ActivityResult}. | ||
*/ | ||
@RunWith(RobolectricTestRunner.class) | ||
@Config(manifest = Config.NONE) | ||
public class ActivityResultTest { | ||
|
||
@Test | ||
public void parcelAndUnparcel_withValidInput_returnsEquivalent() throws Exception { | ||
Parcel parcel = Parcel.obtain(); | ||
|
||
int resultCode = CredentialDeleteResult.CODE_BAD_REQUEST; | ||
Intent intent = CredentialDeleteResult.BAD_REQUEST.toResultDataIntent(); | ||
|
||
// Act | ||
ActivityResult givenActivityResult = ActivityResult.of(resultCode, intent); | ||
givenActivityResult.writeToParcel(parcel, 0 /* flags */); | ||
|
||
parcel.setDataPosition(0); | ||
ActivityResult outputActivityResult = ActivityResult.CREATOR.createFromParcel(parcel); | ||
|
||
// Assert | ||
assertThat(outputActivityResult.getResultCode()).isEqualTo(resultCode); | ||
|
||
CredentialDeleteResult credentialDeleteResult = | ||
CredentialDeleteResult.fromResultIntentData(outputActivityResult.getData()); | ||
assertThat(credentialDeleteResult.getResultCode()).isEqualTo(resultCode); | ||
} | ||
} | ||
package org.openyolo.api.internal; | ||
|
||
import android.content.Intent; | ||
import android.os.Parcel; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.openyolo.protocol.CredentialDeleteResult; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
/** | ||
* Units tests for {@link ActivityResult}. | ||
*/ | ||
@RunWith(RobolectricTestRunner.class) | ||
@Config(manifest = Config.NONE) | ||
public class ActivityResultTest { | ||
|
||
@Test | ||
public void parcelAndUnparcel_withValidInput_returnsEquivalent() throws Exception { | ||
Parcel parcel = Parcel.obtain(); | ||
|
||
int resultCode = CredentialDeleteResult.CODE_BAD_REQUEST; | ||
Intent intent = CredentialDeleteResult.BAD_REQUEST.toResultDataIntent(); | ||
|
||
// Act | ||
ActivityResult givenActivityResult = ActivityResult.of(resultCode, intent); | ||
givenActivityResult.writeToParcel(parcel, 0 /* flags */); | ||
|
||
parcel.setDataPosition(0); | ||
ActivityResult outputActivityResult = ActivityResult.CREATOR.createFromParcel(parcel); | ||
|
||
// Assert | ||
assertThat(outputActivityResult.getResultCode()).isEqualTo(resultCode); | ||
|
||
CredentialDeleteResult credentialDeleteResult = | ||
CredentialDeleteResult.fromResultIntentData(outputActivityResult.getData()); | ||
assertThat(credentialDeleteResult.getResultCode()).isEqualTo(resultCode); | ||
} | ||
} |
170 changes: 85 additions & 85 deletions
170
api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,85 @@ | ||
/* | ||
* Copyright 2017 The OpenYOLO Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.openyolo.api.persistence.internal; | ||
|
||
import android.content.Context; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.openyolo.api.persistence.internal.SettingsFactory.BooleanSetting; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.RuntimeEnvironment; | ||
import org.robolectric.annotation.Config; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
/** Unit tests for {@link org.openyolo.api.persistence.internal.SettingsFactoryImpl} */ | ||
@RunWith(RobolectricTestRunner.class) | ||
@Config(manifest = Config.NONE) | ||
public final class SettingsFactoryImplTest { | ||
|
||
private static final String NAMESPACE_A = "com.namespace.a"; | ||
private static final String NAMESPACE_B = "com.namespace.b"; | ||
private static final String BOOLEAN_KEY = "whatIsLife?"; | ||
private static final Context CONTEXT = RuntimeEnvironment.application; | ||
|
||
private SettingsFactory mSettingsFactoryA; | ||
private SettingsFactory mSettingsFactoryB; | ||
|
||
@Before | ||
public void setup() { | ||
mSettingsFactoryA = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_A); | ||
mSettingsFactoryB = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_B); | ||
} | ||
|
||
@Test | ||
public void makeBooleanSetting_defaultValueFalse_returnsFalse() { | ||
boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, false /* defaultValue */).get(); | ||
assertThat(value).isFalse(); | ||
} | ||
|
||
@Test | ||
public void makeBooleanSetting_defaultValueTrue_returnsTrue() { | ||
boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, true /* defaultValue */).get(); | ||
assertThat(value).isTrue(); | ||
} | ||
|
||
@Test | ||
public void makeBooleansSettings_sameNamespacesSameKey_haveSameValues() { | ||
final String key = "key"; | ||
final Boolean defaultValue = false; | ||
|
||
BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue); | ||
settingA.set(true); | ||
BooleanSetting settingB = mSettingsFactoryA.makeBoolean(key, defaultValue); | ||
|
||
assertThat(settingA.get()).isTrue(); | ||
assertThat(settingB.get()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void makeBooleansSettings_differentNamespacesButSameKey_haveDifferentValues() { | ||
final String key = "key"; | ||
final Boolean defaultValue = false; | ||
|
||
BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue); | ||
settingA.set(true); | ||
BooleanSetting settingB = mSettingsFactoryB.makeBoolean(key, defaultValue); | ||
|
||
assertThat(settingA.get()).isTrue(); | ||
assertThat(settingB.get()).isFalse(); | ||
} | ||
} | ||
/* | ||
* Copyright 2017 The OpenYOLO Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.openyolo.api.persistence.internal; | ||
|
||
import android.content.Context; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.openyolo.api.persistence.internal.SettingsFactory.BooleanSetting; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.RuntimeEnvironment; | ||
import org.robolectric.annotation.Config; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
/** Unit tests for {@link org.openyolo.api.persistence.internal.SettingsFactoryImpl} */ | ||
@RunWith(RobolectricTestRunner.class) | ||
@Config(manifest = Config.NONE) | ||
public final class SettingsFactoryImplTest { | ||
|
||
private static final String NAMESPACE_A = "com.namespace.a"; | ||
private static final String NAMESPACE_B = "com.namespace.b"; | ||
private static final String BOOLEAN_KEY = "whatIsLife?"; | ||
private static final Context CONTEXT = RuntimeEnvironment.application; | ||
|
||
private SettingsFactory mSettingsFactoryA; | ||
private SettingsFactory mSettingsFactoryB; | ||
|
||
@Before | ||
public void setup() { | ||
mSettingsFactoryA = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_A); | ||
mSettingsFactoryB = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_B); | ||
} | ||
|
||
@Test | ||
public void makeBooleanSetting_defaultValueFalse_returnsFalse() { | ||
boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, false /* defaultValue */).get(); | ||
assertThat(value).isFalse(); | ||
} | ||
|
||
@Test | ||
public void makeBooleanSetting_defaultValueTrue_returnsTrue() { | ||
boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, true /* defaultValue */).get(); | ||
assertThat(value).isTrue(); | ||
} | ||
|
||
@Test | ||
public void makeBooleansSettings_sameNamespacesSameKey_haveSameValues() { | ||
final String key = "key"; | ||
final Boolean defaultValue = false; | ||
|
||
BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue); | ||
settingA.set(true); | ||
BooleanSetting settingB = mSettingsFactoryA.makeBoolean(key, defaultValue); | ||
|
||
assertThat(settingA.get()).isTrue(); | ||
assertThat(settingB.get()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void makeBooleansSettings_differentNamespacesButSameKey_haveDifferentValues() { | ||
final String key = "key"; | ||
final Boolean defaultValue = false; | ||
|
||
BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue); | ||
settingA.set(true); | ||
BooleanSetting settingB = mSettingsFactoryB.makeBoolean(key, defaultValue); | ||
|
||
assertThat(settingA.get()).isTrue(); | ||
assertThat(settingB.get()).isFalse(); | ||
} | ||
} |
Oops, something went wrong.