Skip to content

Instantly share code, notes, and snippets.

View Unlimity's full-sized avatar
😴
repo sync -j5

Ilya Lim Unlimity

😴
repo sync -j5
  • Facebook
  • London
View GitHub Profile
@Unlimity
Unlimity / OneTwoTripDemo
Last active April 2, 2016 11:50
This app opens 'input.txt' file in working directory, takes M and N (int) values and then navigates through M lines on N symbols and tries to find combinations of characters that represents 'OneTwoTrip' string (no case sensitive) and then outputs found characters positions or 'Impossible' if there is no solution.
package com.alviere.onetwotrip;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
private static final int NEEDED_STRING_SIZE = 10;
@Test
public void espressoTest() {
onView(allOf(allOf(withId(R.id.label_bf_hotelname),
isDescendantOfA(withId(R.id.custom_view_trip_review))),
isDescendantOfA(withId(R.id.contentView))))
.check(matches(withEffectiveVisibility(View.VISIBLE)));
}
@Test
fun espressoTest() {
screen { hotelName { isVisible() } }
}
open class TestActivityScreen: Screen<TestActivityScreen>() {
val content: KView = KView { withId(R.id.content) }
val map: KView = KView { withId(R.id.map) }
val button: KButton = KButton { withId(R.id.button) }
val textViewLarge: KTextView = KTextView {
withId(R.id.text_view_large)
}
val textViewSmall: KTextView = KTextView {
class KTextView : KBaseView<KTextView>, TextViewAssertions {
constructor(function: ViewBuilder.() -> Unit): super(function)
constructor(parent: Matcher<View>, function: ViewBuilder.() -> Unit): super(parent, function)
constructor(parent: DataInteraction, function: ViewBuilder.() -> Unit): super(parent, function)
}
@RunWith(AndroidJUnit4::class)
class TestActivityTest {
@Rule
@JvmField
val rule = ActivityTestRule(TestActivity::class.java)
val screen = TestActivityScreen()
@Test
fun test() {
@Unlimity
Unlimity / SubclassBytecodeGenerator.java
Created February 23, 2018 11:11
SubclassBytecodeGenerator
@Override
public <T> Class<? extends T> mockClass(MockFeatures<T> features) {
DynamicType.Builder<T> builder =
byteBuddy.subclass(features.mockedType)
.name(nameFor(features.mockedType))
.ignoreAlso(isGroovyMethod())
.annotateType(features.stripAnnotations
? new Annotation[0]
: features.mockedType.getAnnotations())
.implement(new ArrayList<Type>(features.interfaces))
@Unlimity
Unlimity / MockMethodInterceptor.java
Created February 26, 2018 07:58
DispatcherDefaultingToRealMethod
public class MockMethodInterceptor implements Serializable {
...
public static class DispatcherDefaultingToRealMethod {
@SuppressWarnings("unused")
@RuntimeType
@BindingPriority(BindingPriority.DEFAULT * 2)
public static Object interceptSuperCallable(@This Object mock,
@Unlimity
Unlimity / OpenClassCompiledMock.java
Created February 26, 2018 08:08
SampleCompiledMock
public class OpenClassCompiledMock extends OpenClass implements MockAccess {
private MockMethodInterceptor mockitoInterceptor;
public OpenClassCompiledMock() {
super(null);
}
@Override
public MockMethodInterceptor getMockitoInterceptor() {
return mockitoInterceptor;
@Unlimity
Unlimity / TonikExceptions.java
Created February 26, 2018 08:35
Exceptions
public final class TonikExceptions {
private TonikExceptions() {
}
public static void throwException(Throwable exception) {
throwException(exception, null);
}
@SuppressWarnings("unchecked")