-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Patryk Wrobel <[email protected]>
- Loading branch information
1 parent
6519c60
commit e8dac33
Showing
56 changed files
with
2,613 additions
and
20 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
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
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
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
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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
...ests/functional/android-kotlin/src/test/kotlin/com/here/android/RobolectricApplication.kt
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2016-2025 HERE Europe B.V. | ||
* | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
|
||
package com.here.android | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Application | ||
import android.util.Log | ||
import com.here.android.lorem.ipsum.NativeBase | ||
import com.here.gluecodium.test.functional.BuildConfig | ||
import org.powermock.reflect.Whitebox | ||
import org.robolectric.shadows.ShadowLog | ||
import java.io.File | ||
|
||
class RobolectricApplication : Application() { | ||
private val TAG: String = RobolectricApplication::class.java.getSimpleName() | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
if (isFirstTime) { | ||
isFirstTime = false | ||
|
||
loadNativeLibraries(); | ||
Runtime.getRuntime().addShutdownHook(Thread{ | ||
try { | ||
Whitebox.invokeMethod(NativeBase::class.java, "cleanUpQueue") | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} | ||
}) | ||
} | ||
} | ||
|
||
/** | ||
* Separate method to load libraries in case you want to subclass and can't load in onCreate(). | ||
*/ | ||
@SuppressLint("UnsafeDynamicallyLoadedCode") | ||
private fun loadNativeLibraries() { | ||
val appLibraryPath: java.io.File = java.io.File(BuildConfig.NATIVE_LIB_HOST_DIR) | ||
|
||
Log.d(TAG, "loadNativeLibraries: Using app library path: " + appLibraryPath) | ||
|
||
val files = appLibraryPath.listFiles { | ||
dir, name -> name.contains(".so") || name.endsWith(".dylib") | ||
} | ||
|
||
for (sharedObject in files) { | ||
Log.i(TAG, "loadNativeLibraries: Loading app library '" + sharedObject.getName() + "'...") | ||
System.load(sharedObject.getAbsolutePath()) | ||
} | ||
} | ||
|
||
companion object { | ||
private var isFirstTime: Boolean = true | ||
|
||
init { | ||
ShadowLog.stream = System.out // Android logcat output. | ||
} | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
...al-tests/functional/android-kotlin/src/test/kotlin/com/here/android/test/InstancesTest.kt
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (C) 2016-2025 HERE Europe B.V. | ||
* | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
package com.here.android.test | ||
|
||
import com.here.android.RobolectricApplication | ||
import org.junit.Assert.assertEquals | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
@Config(application = RobolectricApplication::class) | ||
class InstancesTest { | ||
@org.junit.Test | ||
fun setSameTypeInstances() { | ||
val instanceOne: SimpleInstantiableOne = InstancesFactory.createSimpleInstantiableOne() | ||
val instanceTwo: SimpleInstantiableOne = InstancesFactory.createSimpleInstantiableOne() | ||
val nestedInstanceOne: NestedInstantiableOne = InstancesFactory.createNestedInstantiableOne() | ||
instanceOne.setStringValue(INSTANCE_ONE_STRING) | ||
instanceTwo.setStringValue(INSTANCE_TWO_STRING) | ||
|
||
nestedInstanceOne.setSameTypeInstances(instanceOne, instanceTwo) | ||
|
||
val resultOne: SimpleInstantiableOne = nestedInstanceOne.getInstanceOne() | ||
val resultTwo: SimpleInstantiableOne = nestedInstanceOne.getInstanceTwo() | ||
assertEquals(INSTANCE_ONE_STRING, resultOne.getStringValue()) | ||
assertEquals(INSTANCE_TWO_STRING, resultTwo.getStringValue()) | ||
} | ||
|
||
@org.junit.Test | ||
fun setSameTypeInstances_identicalInstances() { | ||
val instanceOne: SimpleInstantiableOne = InstancesFactory.createSimpleInstantiableOne() | ||
val nestedInstanceOne: NestedInstantiableOne = InstancesFactory.createNestedInstantiableOne() | ||
instanceOne.setStringValue(INSTANCE_ONE_STRING) | ||
|
||
nestedInstanceOne.setSameTypeInstances(instanceOne, instanceOne) | ||
|
||
val resultOne: SimpleInstantiableOne = nestedInstanceOne.getInstanceOne() | ||
val resultTwo: SimpleInstantiableOne = nestedInstanceOne.getInstanceTwo() | ||
assertEquals(INSTANCE_ONE_STRING, resultOne.getStringValue()) | ||
assertEquals(INSTANCE_ONE_STRING, resultTwo.getStringValue()) | ||
} | ||
|
||
@org.junit.Test | ||
fun setMultipleTypeInstances() { | ||
val simpleInstanceOne: SimpleInstantiableOne = InstancesFactory.createSimpleInstantiableOne() | ||
val otherInstanceOne: SimpleInstantiableOne = InstancesFactory.createSimpleInstantiableOne() | ||
val simpleInstanceTwo: SimpleInstantiableTwo = InstancesFactory.createSimpleInstantiableTwo() | ||
val nested: NestedInstantiableOne = InstancesFactory.createNestedInstantiableOne() | ||
val nestedInstantiableTwo: NestedInstantiableTwo = InstancesFactory.createNestedInstantiableTwo() | ||
simpleInstanceOne.setStringValue(INSTANCE_ONE_STRING) | ||
simpleInstanceTwo.setStringValue(INSTANCE_TWO_STRING) | ||
otherInstanceOne.setStringValue(INSTANCE_OTHER_STRING) | ||
nested.setSameTypeInstances(simpleInstanceOne, otherInstanceOne) | ||
|
||
nestedInstantiableTwo.setMultipleTypeInstances(simpleInstanceOne, simpleInstanceTwo, nested) | ||
|
||
assertEquals(INSTANCE_ONE_STRING, nestedInstantiableTwo.getInstantiableOne().getStringValue()) | ||
assertEquals(INSTANCE_TWO_STRING, nestedInstantiableTwo.getInstantiableTwo().getStringValue()) | ||
val nestedInstantiable: NestedInstantiableOne = nestedInstantiableTwo.getNestedInstantiable() | ||
assertEquals(INSTANCE_ONE_STRING, nestedInstantiable.getInstanceOne().getStringValue()) | ||
assertEquals(INSTANCE_OTHER_STRING, nestedInstantiable.getInstanceTwo().getStringValue()) | ||
} | ||
|
||
@org.junit.Test | ||
fun setSelfInstantiable() { | ||
val simpleOne: SimpleInstantiableOne = InstancesFactory.createSimpleInstantiableOne() | ||
simpleOne.setStringValue(INSTANCE_ONE_STRING) | ||
|
||
val simpleTwo: SimpleInstantiableTwo = InstancesFactory.createSimpleInstantiableTwo() | ||
simpleTwo.setStringValue(INSTANCE_TWO_STRING) | ||
|
||
val nestedOne: NestedInstantiableOne = InstancesFactory.createNestedInstantiableOne() | ||
val nestedTwo: NestedInstantiableTwo = InstancesFactory.createNestedInstantiableTwo() | ||
nestedTwo.setMultipleTypeInstances(simpleOne, simpleTwo, nestedOne) | ||
nestedTwo.setSelfInstantiable(nestedTwo) | ||
|
||
val selfInstantiable: NestedInstantiableTwo = nestedTwo.getSelfInstantiable() | ||
assertEquals(INSTANCE_ONE_STRING, selfInstantiable.getInstantiableOne().getStringValue()) | ||
assertEquals(INSTANCE_TWO_STRING, selfInstantiable.getInstantiableTwo().getStringValue()) | ||
} | ||
|
||
companion object { | ||
private const val INSTANCE_ONE_STRING: String = "simpleInstanceOne" | ||
private const val INSTANCE_TWO_STRING: String = "simpleInstanceTwo" | ||
private const val INSTANCE_OTHER_STRING: String = "simpleInstanceOther" | ||
} | ||
} |
Oops, something went wrong.