repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
|---|---|---|---|---|---|---|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/Cursor.java
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
|
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
|
* <p>
* This call is only valid on databases that support sorted duplicate data
* items {@link DbiFlags#MDB_DUPSORT}.
*
* @return count of duplicates for current key
*/
public long count() {
if (SHOULD_CHECK) {
checkNotClosed();
txn.checkReady();
}
final NativeLongByReference longByReference = new NativeLongByReference();
checkRc(LIB.mdb_cursor_count(ptrCursor, longByReference));
return longByReference.longValue();
}
/**
* Delete current key/data pair.
*
* <p>
* This function deletes the key/data pair to which the cursor refers.
*
* @param f flags (either null or {@link PutFlags#MDB_NODUPDATA}
*/
public void delete(final PutFlags... f) {
if (SHOULD_CHECK) {
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
// Path: src/main/java/org/lmdbjava/Cursor.java
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
* <p>
* This call is only valid on databases that support sorted duplicate data
* items {@link DbiFlags#MDB_DUPSORT}.
*
* @return count of duplicates for current key
*/
public long count() {
if (SHOULD_CHECK) {
checkNotClosed();
txn.checkReady();
}
final NativeLongByReference longByReference = new NativeLongByReference();
checkRc(LIB.mdb_cursor_count(ptrCursor, longByReference));
return longByReference.longValue();
}
/**
* Delete current key/data pair.
*
* <p>
* This function deletes the key/data pair to which the cursor refers.
*
* @param f flags (either null or {@link PutFlags#MDB_NODUPDATA}
*/
public void delete(final PutFlags... f) {
if (SHOULD_CHECK) {
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
|
final int flags = mask(f);
|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/Cursor.java
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
|
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
|
/**
* Position at first key/data item.
*
* @return false if requested position not found
*/
public boolean first() {
return seek(MDB_FIRST);
}
/**
* Reposition the key/value buffers based on the passed key and operation.
*
* @param key to search for
* @param data to search for
* @param op options for this operation
* @return false if key not found
*/
public boolean get(final T key, final T data, final SeekOp op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(op);
checkNotClosed();
txn.checkReady();
}
kv.keyIn(key);
kv.valIn(data);
final int rc = LIB.mdb_cursor_get(ptrCursor, kv.pointerKey(), kv
.pointerVal(), op.getCode());
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
// Path: src/main/java/org/lmdbjava/Cursor.java
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
/**
* Position at first key/data item.
*
* @return false if requested position not found
*/
public boolean first() {
return seek(MDB_FIRST);
}
/**
* Reposition the key/value buffers based on the passed key and operation.
*
* @param key to search for
* @param data to search for
* @param op options for this operation
* @return false if key not found
*/
public boolean get(final T key, final T data, final SeekOp op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(op);
checkNotClosed();
txn.checkReady();
}
kv.keyIn(key);
kv.valIn(data);
final int rc = LIB.mdb_cursor_get(ptrCursor, kv.pointerKey(), kv
.pointerVal(), op.getCode());
|
if (rc == MDB_NOTFOUND) {
|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/Cursor.java
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
|
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
|
*/
public boolean prev() {
return seek(MDB_PREV);
}
/**
* Store by cursor.
*
* <p>
* This function stores key/data pairs into the database.
*
* @param key key to store
* @param val data to store
* @param op options for this operation
* @return true if the value was put, false if MDB_NOOVERWRITE or
* MDB_NODUPDATA were set and the key/value existed already.
*/
public boolean put(final T key, final T val, final PutFlags... op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(val);
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
kv.keyIn(key);
kv.valIn(val);
final int mask = mask(op);
final int rc = LIB.mdb_cursor_put(ptrCursor, kv.pointerKey(),
kv.pointerVal(), mask);
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
// Path: src/main/java/org/lmdbjava/Cursor.java
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
*/
public boolean prev() {
return seek(MDB_PREV);
}
/**
* Store by cursor.
*
* <p>
* This function stores key/data pairs into the database.
*
* @param key key to store
* @param val data to store
* @param op options for this operation
* @return true if the value was put, false if MDB_NOOVERWRITE or
* MDB_NODUPDATA were set and the key/value existed already.
*/
public boolean put(final T key, final T val, final PutFlags... op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(val);
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
kv.keyIn(key);
kv.valIn(val);
final int mask = mask(op);
final int rc = LIB.mdb_cursor_put(ptrCursor, kv.pointerKey(),
kv.pointerVal(), mask);
|
if (rc == MDB_KEYEXIST) {
|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/Cursor.java
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
|
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
|
public boolean prev() {
return seek(MDB_PREV);
}
/**
* Store by cursor.
*
* <p>
* This function stores key/data pairs into the database.
*
* @param key key to store
* @param val data to store
* @param op options for this operation
* @return true if the value was put, false if MDB_NOOVERWRITE or
* MDB_NODUPDATA were set and the key/value existed already.
*/
public boolean put(final T key, final T val, final PutFlags... op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(val);
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
kv.keyIn(key);
kv.valIn(val);
final int mask = mask(op);
final int rc = LIB.mdb_cursor_put(ptrCursor, kv.pointerKey(),
kv.pointerVal(), mask);
if (rc == MDB_KEYEXIST) {
|
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_KEYEXIST = -30_799;
//
// Path: src/main/java/org/lmdbjava/Dbi.java
// static final int MDB_NOTFOUND = -30_798;
//
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
//
// Path: src/main/java/org/lmdbjava/Library.java
// static final Lmdb LIB;
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static boolean isSet(final int flags, final MaskedFlag test) {
// requireNonNull(test);
// return (flags & test.getMask()) == test.getMask();
// }
//
// Path: src/main/java/org/lmdbjava/MaskedFlag.java
// static int mask(final MaskedFlag... flags) {
// if (flags == null || flags.length == 0) {
// return 0;
// }
//
// int result = 0;
// for (final MaskedFlag flag : flags) {
// if (flag == null) {
// continue;
// }
// result |= flag.getMask();
// }
// return result;
// }
//
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
// static void checkRc(final int rc) {
// switch (rc) {
// case MDB_SUCCESS:
// return;
// case Dbi.BadDbiException.MDB_BAD_DBI:
// throw new Dbi.BadDbiException();
// case BadReaderLockException.MDB_BAD_RSLOT:
// throw new BadReaderLockException();
// case BadException.MDB_BAD_TXN:
// throw new BadException();
// case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
// throw new Dbi.BadValueSizeException();
// case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
// throw new LmdbNativeException.PageCorruptedException();
// case Cursor.FullException.MDB_CURSOR_FULL:
// throw new Cursor.FullException();
// case Dbi.DbFullException.MDB_DBS_FULL:
// throw new Dbi.DbFullException();
// case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
// throw new Dbi.IncompatibleException();
// case Env.FileInvalidException.MDB_INVALID:
// throw new Env.FileInvalidException();
// case Dbi.KeyExistsException.MDB_KEYEXIST:
// throw new Dbi.KeyExistsException();
// case Env.MapFullException.MDB_MAP_FULL:
// throw new Env.MapFullException();
// case Dbi.MapResizedException.MDB_MAP_RESIZED:
// throw new Dbi.MapResizedException();
// case Dbi.KeyNotFoundException.MDB_NOTFOUND:
// throw new Dbi.KeyNotFoundException();
// case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
// throw new LmdbNativeException.PageFullException();
// case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
// throw new LmdbNativeException.PageNotFoundException();
// case LmdbNativeException.PanicException.MDB_PANIC:
// throw new LmdbNativeException.PanicException();
// case Env.ReadersFullException.MDB_READERS_FULL:
// throw new Env.ReadersFullException();
// case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
// throw new LmdbNativeException.TlsFullException();
// case TxFullException.MDB_TXN_FULL:
// throw new TxFullException();
// case Env.VersionMismatchException.MDB_VERSION_MISMATCH:
// throw new Env.VersionMismatchException();
// default:
// break;
// }
//
// final Constant constant = CONSTANTS.getConstant(rc);
// if (constant == null) {
// throw new IllegalArgumentException("Unknown result code " + rc);
// }
// final String msg = constant.name() + " " + constant.toString();
// throw new LmdbNativeException.ConstantDerivedException(rc, msg);
// }
// Path: src/main/java/org/lmdbjava/Cursor.java
import static org.lmdbjava.PutFlags.MDB_RESERVE;
import static org.lmdbjava.ResultCodeMapper.checkRc;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_NEXT;
import static org.lmdbjava.SeekOp.MDB_PREV;
import jnr.ffi.Pointer;
import jnr.ffi.byref.NativeLongByReference;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.Library.LIB;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
public boolean prev() {
return seek(MDB_PREV);
}
/**
* Store by cursor.
*
* <p>
* This function stores key/data pairs into the database.
*
* @param key key to store
* @param val data to store
* @param op options for this operation
* @return true if the value was put, false if MDB_NOOVERWRITE or
* MDB_NODUPDATA were set and the key/value existed already.
*/
public boolean put(final T key, final T val, final PutFlags... op) {
if (SHOULD_CHECK) {
requireNonNull(key);
requireNonNull(val);
checkNotClosed();
txn.checkReady();
txn.checkWritesAllowed();
}
kv.keyIn(key);
kv.valIn(val);
final int mask = mask(op);
final int rc = LIB.mdb_cursor_put(ptrCursor, kv.pointerKey(),
kv.pointerVal(), mask);
if (rc == MDB_KEYEXIST) {
|
if (isSet(mask, MDB_NOOVERWRITE)) {
|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/ResultCodeMapper.java
|
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadException extends LmdbNativeException {
//
// static final int MDB_BAD_TXN = -30_782;
// private static final long serialVersionUID = 1L;
//
// BadException() {
// super(MDB_BAD_TXN, "Transaction must abort, has a child, or is invalid");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadReaderLockException extends LmdbNativeException {
//
// static final int MDB_BAD_RSLOT = -30_783;
// private static final long serialVersionUID = 1L;
//
// BadReaderLockException() {
// super(MDB_BAD_RSLOT, "Invalid reuse of reader locktable slot");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class TxFullException extends LmdbNativeException {
//
// static final int MDB_TXN_FULL = -30_788;
// private static final long serialVersionUID = 1L;
//
// TxFullException() {
// super(MDB_TXN_FULL, "Transaction has too many dirty pages");
// }
// }
|
import static jnr.constants.ConstantSet.getConstantSet;
import jnr.constants.Constant;
import jnr.constants.ConstantSet;
import org.lmdbjava.Txn.BadException;
import org.lmdbjava.Txn.BadReaderLockException;
import org.lmdbjava.Txn.TxFullException;
|
/*-
* #%L
* LmdbJava
* %%
* Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
* %%
* 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.
* #L%
*/
package org.lmdbjava;
/**
* Maps a LMDB C result code to the equivalent Java exception.
*
* <p>
* The immutable nature of all LMDB exceptions means the mapper internally
* maintains a table of them.
*/
@SuppressWarnings("PMD.CyclomaticComplexity")
final class ResultCodeMapper {
/**
* Successful result.
*/
static final int MDB_SUCCESS = 0;
private static final ConstantSet CONSTANTS;
private static final String POSIX_ERR_NO = "Errno";
static {
CONSTANTS = getConstantSet(POSIX_ERR_NO);
}
private ResultCodeMapper() {
}
/**
* Checks the result code and raises an exception is not {@link #MDB_SUCCESS}.
*
* @param rc the LMDB result code
*/
static void checkRc(final int rc) {
switch (rc) {
case MDB_SUCCESS:
return;
case Dbi.BadDbiException.MDB_BAD_DBI:
throw new Dbi.BadDbiException();
|
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadException extends LmdbNativeException {
//
// static final int MDB_BAD_TXN = -30_782;
// private static final long serialVersionUID = 1L;
//
// BadException() {
// super(MDB_BAD_TXN, "Transaction must abort, has a child, or is invalid");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadReaderLockException extends LmdbNativeException {
//
// static final int MDB_BAD_RSLOT = -30_783;
// private static final long serialVersionUID = 1L;
//
// BadReaderLockException() {
// super(MDB_BAD_RSLOT, "Invalid reuse of reader locktable slot");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class TxFullException extends LmdbNativeException {
//
// static final int MDB_TXN_FULL = -30_788;
// private static final long serialVersionUID = 1L;
//
// TxFullException() {
// super(MDB_TXN_FULL, "Transaction has too many dirty pages");
// }
// }
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
import static jnr.constants.ConstantSet.getConstantSet;
import jnr.constants.Constant;
import jnr.constants.ConstantSet;
import org.lmdbjava.Txn.BadException;
import org.lmdbjava.Txn.BadReaderLockException;
import org.lmdbjava.Txn.TxFullException;
/*-
* #%L
* LmdbJava
* %%
* Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
* %%
* 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.
* #L%
*/
package org.lmdbjava;
/**
* Maps a LMDB C result code to the equivalent Java exception.
*
* <p>
* The immutable nature of all LMDB exceptions means the mapper internally
* maintains a table of them.
*/
@SuppressWarnings("PMD.CyclomaticComplexity")
final class ResultCodeMapper {
/**
* Successful result.
*/
static final int MDB_SUCCESS = 0;
private static final ConstantSet CONSTANTS;
private static final String POSIX_ERR_NO = "Errno";
static {
CONSTANTS = getConstantSet(POSIX_ERR_NO);
}
private ResultCodeMapper() {
}
/**
* Checks the result code and raises an exception is not {@link #MDB_SUCCESS}.
*
* @param rc the LMDB result code
*/
static void checkRc(final int rc) {
switch (rc) {
case MDB_SUCCESS:
return;
case Dbi.BadDbiException.MDB_BAD_DBI:
throw new Dbi.BadDbiException();
|
case BadReaderLockException.MDB_BAD_RSLOT:
|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/ResultCodeMapper.java
|
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadException extends LmdbNativeException {
//
// static final int MDB_BAD_TXN = -30_782;
// private static final long serialVersionUID = 1L;
//
// BadException() {
// super(MDB_BAD_TXN, "Transaction must abort, has a child, or is invalid");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadReaderLockException extends LmdbNativeException {
//
// static final int MDB_BAD_RSLOT = -30_783;
// private static final long serialVersionUID = 1L;
//
// BadReaderLockException() {
// super(MDB_BAD_RSLOT, "Invalid reuse of reader locktable slot");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class TxFullException extends LmdbNativeException {
//
// static final int MDB_TXN_FULL = -30_788;
// private static final long serialVersionUID = 1L;
//
// TxFullException() {
// super(MDB_TXN_FULL, "Transaction has too many dirty pages");
// }
// }
|
import static jnr.constants.ConstantSet.getConstantSet;
import jnr.constants.Constant;
import jnr.constants.ConstantSet;
import org.lmdbjava.Txn.BadException;
import org.lmdbjava.Txn.BadReaderLockException;
import org.lmdbjava.Txn.TxFullException;
|
/*-
* #%L
* LmdbJava
* %%
* Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
* %%
* 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.
* #L%
*/
package org.lmdbjava;
/**
* Maps a LMDB C result code to the equivalent Java exception.
*
* <p>
* The immutable nature of all LMDB exceptions means the mapper internally
* maintains a table of them.
*/
@SuppressWarnings("PMD.CyclomaticComplexity")
final class ResultCodeMapper {
/**
* Successful result.
*/
static final int MDB_SUCCESS = 0;
private static final ConstantSet CONSTANTS;
private static final String POSIX_ERR_NO = "Errno";
static {
CONSTANTS = getConstantSet(POSIX_ERR_NO);
}
private ResultCodeMapper() {
}
/**
* Checks the result code and raises an exception is not {@link #MDB_SUCCESS}.
*
* @param rc the LMDB result code
*/
static void checkRc(final int rc) {
switch (rc) {
case MDB_SUCCESS:
return;
case Dbi.BadDbiException.MDB_BAD_DBI:
throw new Dbi.BadDbiException();
case BadReaderLockException.MDB_BAD_RSLOT:
throw new BadReaderLockException();
|
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadException extends LmdbNativeException {
//
// static final int MDB_BAD_TXN = -30_782;
// private static final long serialVersionUID = 1L;
//
// BadException() {
// super(MDB_BAD_TXN, "Transaction must abort, has a child, or is invalid");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadReaderLockException extends LmdbNativeException {
//
// static final int MDB_BAD_RSLOT = -30_783;
// private static final long serialVersionUID = 1L;
//
// BadReaderLockException() {
// super(MDB_BAD_RSLOT, "Invalid reuse of reader locktable slot");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class TxFullException extends LmdbNativeException {
//
// static final int MDB_TXN_FULL = -30_788;
// private static final long serialVersionUID = 1L;
//
// TxFullException() {
// super(MDB_TXN_FULL, "Transaction has too many dirty pages");
// }
// }
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
import static jnr.constants.ConstantSet.getConstantSet;
import jnr.constants.Constant;
import jnr.constants.ConstantSet;
import org.lmdbjava.Txn.BadException;
import org.lmdbjava.Txn.BadReaderLockException;
import org.lmdbjava.Txn.TxFullException;
/*-
* #%L
* LmdbJava
* %%
* Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
* %%
* 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.
* #L%
*/
package org.lmdbjava;
/**
* Maps a LMDB C result code to the equivalent Java exception.
*
* <p>
* The immutable nature of all LMDB exceptions means the mapper internally
* maintains a table of them.
*/
@SuppressWarnings("PMD.CyclomaticComplexity")
final class ResultCodeMapper {
/**
* Successful result.
*/
static final int MDB_SUCCESS = 0;
private static final ConstantSet CONSTANTS;
private static final String POSIX_ERR_NO = "Errno";
static {
CONSTANTS = getConstantSet(POSIX_ERR_NO);
}
private ResultCodeMapper() {
}
/**
* Checks the result code and raises an exception is not {@link #MDB_SUCCESS}.
*
* @param rc the LMDB result code
*/
static void checkRc(final int rc) {
switch (rc) {
case MDB_SUCCESS:
return;
case Dbi.BadDbiException.MDB_BAD_DBI:
throw new Dbi.BadDbiException();
case BadReaderLockException.MDB_BAD_RSLOT:
throw new BadReaderLockException();
|
case BadException.MDB_BAD_TXN:
|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/ResultCodeMapper.java
|
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadException extends LmdbNativeException {
//
// static final int MDB_BAD_TXN = -30_782;
// private static final long serialVersionUID = 1L;
//
// BadException() {
// super(MDB_BAD_TXN, "Transaction must abort, has a child, or is invalid");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadReaderLockException extends LmdbNativeException {
//
// static final int MDB_BAD_RSLOT = -30_783;
// private static final long serialVersionUID = 1L;
//
// BadReaderLockException() {
// super(MDB_BAD_RSLOT, "Invalid reuse of reader locktable slot");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class TxFullException extends LmdbNativeException {
//
// static final int MDB_TXN_FULL = -30_788;
// private static final long serialVersionUID = 1L;
//
// TxFullException() {
// super(MDB_TXN_FULL, "Transaction has too many dirty pages");
// }
// }
|
import static jnr.constants.ConstantSet.getConstantSet;
import jnr.constants.Constant;
import jnr.constants.ConstantSet;
import org.lmdbjava.Txn.BadException;
import org.lmdbjava.Txn.BadReaderLockException;
import org.lmdbjava.Txn.TxFullException;
|
case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
throw new Dbi.BadValueSizeException();
case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
throw new LmdbNativeException.PageCorruptedException();
case Cursor.FullException.MDB_CURSOR_FULL:
throw new Cursor.FullException();
case Dbi.DbFullException.MDB_DBS_FULL:
throw new Dbi.DbFullException();
case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
throw new Dbi.IncompatibleException();
case Env.FileInvalidException.MDB_INVALID:
throw new Env.FileInvalidException();
case Dbi.KeyExistsException.MDB_KEYEXIST:
throw new Dbi.KeyExistsException();
case Env.MapFullException.MDB_MAP_FULL:
throw new Env.MapFullException();
case Dbi.MapResizedException.MDB_MAP_RESIZED:
throw new Dbi.MapResizedException();
case Dbi.KeyNotFoundException.MDB_NOTFOUND:
throw new Dbi.KeyNotFoundException();
case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
throw new LmdbNativeException.PageFullException();
case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
throw new LmdbNativeException.PageNotFoundException();
case LmdbNativeException.PanicException.MDB_PANIC:
throw new LmdbNativeException.PanicException();
case Env.ReadersFullException.MDB_READERS_FULL:
throw new Env.ReadersFullException();
case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
throw new LmdbNativeException.TlsFullException();
|
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadException extends LmdbNativeException {
//
// static final int MDB_BAD_TXN = -30_782;
// private static final long serialVersionUID = 1L;
//
// BadException() {
// super(MDB_BAD_TXN, "Transaction must abort, has a child, or is invalid");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class BadReaderLockException extends LmdbNativeException {
//
// static final int MDB_BAD_RSLOT = -30_783;
// private static final long serialVersionUID = 1L;
//
// BadReaderLockException() {
// super(MDB_BAD_RSLOT, "Invalid reuse of reader locktable slot");
// }
// }
//
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class TxFullException extends LmdbNativeException {
//
// static final int MDB_TXN_FULL = -30_788;
// private static final long serialVersionUID = 1L;
//
// TxFullException() {
// super(MDB_TXN_FULL, "Transaction has too many dirty pages");
// }
// }
// Path: src/main/java/org/lmdbjava/ResultCodeMapper.java
import static jnr.constants.ConstantSet.getConstantSet;
import jnr.constants.Constant;
import jnr.constants.ConstantSet;
import org.lmdbjava.Txn.BadException;
import org.lmdbjava.Txn.BadReaderLockException;
import org.lmdbjava.Txn.TxFullException;
case Dbi.BadValueSizeException.MDB_BAD_VALSIZE:
throw new Dbi.BadValueSizeException();
case LmdbNativeException.PageCorruptedException.MDB_CORRUPTED:
throw new LmdbNativeException.PageCorruptedException();
case Cursor.FullException.MDB_CURSOR_FULL:
throw new Cursor.FullException();
case Dbi.DbFullException.MDB_DBS_FULL:
throw new Dbi.DbFullException();
case Dbi.IncompatibleException.MDB_INCOMPATIBLE:
throw new Dbi.IncompatibleException();
case Env.FileInvalidException.MDB_INVALID:
throw new Env.FileInvalidException();
case Dbi.KeyExistsException.MDB_KEYEXIST:
throw new Dbi.KeyExistsException();
case Env.MapFullException.MDB_MAP_FULL:
throw new Env.MapFullException();
case Dbi.MapResizedException.MDB_MAP_RESIZED:
throw new Dbi.MapResizedException();
case Dbi.KeyNotFoundException.MDB_NOTFOUND:
throw new Dbi.KeyNotFoundException();
case LmdbNativeException.PageFullException.MDB_PAGE_FULL:
throw new LmdbNativeException.PageFullException();
case LmdbNativeException.PageNotFoundException.MDB_PAGE_NOTFOUND:
throw new LmdbNativeException.PageNotFoundException();
case LmdbNativeException.PanicException.MDB_PANIC:
throw new LmdbNativeException.PanicException();
case Env.ReadersFullException.MDB_READERS_FULL:
throw new Env.ReadersFullException();
case LmdbNativeException.TlsFullException.MDB_TLS_FULL:
throw new LmdbNativeException.TlsFullException();
|
case TxFullException.MDB_TXN_FULL:
|
jabbink/PokemonGoAPI
|
src/main/java/ink/abb/pogo/api/auth/CredentialProvider.java
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
|
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import java.util.concurrent.TimeUnit;
|
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ink.abb.pogo.api.auth;
/**
* Any Credential Provider can extend this.
*/
public abstract class CredentialProvider {
public static final long REFRESH_TOKEN_BUFFER_TIME = TimeUnit.MINUTES.toMillis(5);
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
// Path: src/main/java/ink/abb/pogo/api/auth/CredentialProvider.java
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import java.util.concurrent.TimeUnit;
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ink.abb.pogo.api.auth;
/**
* Any Credential Provider can extend this.
*/
public abstract class CredentialProvider {
public static final long REFRESH_TOKEN_BUFFER_TIME = TimeUnit.MINUTES.toMillis(5);
|
public abstract String getTokenId() throws LoginFailedException, RemoteServerException;
|
jabbink/PokemonGoAPI
|
src/main/java/ink/abb/pogo/api/auth/CredentialProvider.java
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
|
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import java.util.concurrent.TimeUnit;
|
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ink.abb.pogo.api.auth;
/**
* Any Credential Provider can extend this.
*/
public abstract class CredentialProvider {
public static final long REFRESH_TOKEN_BUFFER_TIME = TimeUnit.MINUTES.toMillis(5);
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
// Path: src/main/java/ink/abb/pogo/api/auth/CredentialProvider.java
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import java.util.concurrent.TimeUnit;
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ink.abb.pogo.api.auth;
/**
* Any Credential Provider can extend this.
*/
public abstract class CredentialProvider {
public static final long REFRESH_TOKEN_BUFFER_TIME = TimeUnit.MINUTES.toMillis(5);
|
public abstract String getTokenId() throws LoginFailedException, RemoteServerException;
|
jabbink/PokemonGoAPI
|
src/main/java/ink/abb/pogo/api/auth/PtcCredentialProvider.java
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
|
import java.util.zip.GZIPInputStream;
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import com.squareup.moshi.Moshi;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import okhttp3.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
|
//Makes sure the User-Agent is always set
Request req = chain.request();
req = req.newBuilder().header("User-Agent", TrishulaDragonOfTheIceBarrier).build();
return chain.proceed(req);
}
})
.build();
authbuilder = AuthInfo.newBuilder();
}
private String readDeck(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
/**
* Starts a login flow for pokemon.com (PTC) using a username and password,
* this uses pokemon.com's oauth endpoint and returns a usable AuthInfo without user interaction
*/
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
// Path: src/main/java/ink/abb/pogo/api/auth/PtcCredentialProvider.java
import java.util.zip.GZIPInputStream;
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import com.squareup.moshi.Moshi;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import okhttp3.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
//Makes sure the User-Agent is always set
Request req = chain.request();
req = req.newBuilder().header("User-Agent", TrishulaDragonOfTheIceBarrier).build();
return chain.proceed(req);
}
})
.build();
authbuilder = AuthInfo.newBuilder();
}
private String readDeck(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
/**
* Starts a login flow for pokemon.com (PTC) using a username and password,
* this uses pokemon.com's oauth endpoint and returns a usable AuthInfo without user interaction
*/
|
public void login() throws LoginFailedException, RemoteServerException {
|
jabbink/PokemonGoAPI
|
src/main/java/ink/abb/pogo/api/auth/PtcCredentialProvider.java
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
|
import java.util.zip.GZIPInputStream;
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import com.squareup.moshi.Moshi;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import okhttp3.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
|
//Makes sure the User-Agent is always set
Request req = chain.request();
req = req.newBuilder().header("User-Agent", TrishulaDragonOfTheIceBarrier).build();
return chain.proceed(req);
}
})
.build();
authbuilder = AuthInfo.newBuilder();
}
private String readDeck(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
/**
* Starts a login flow for pokemon.com (PTC) using a username and password,
* this uses pokemon.com's oauth endpoint and returns a usable AuthInfo without user interaction
*/
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
// Path: src/main/java/ink/abb/pogo/api/auth/PtcCredentialProvider.java
import java.util.zip.GZIPInputStream;
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import com.squareup.moshi.Moshi;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import okhttp3.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
//Makes sure the User-Agent is always set
Request req = chain.request();
req = req.newBuilder().header("User-Agent", TrishulaDragonOfTheIceBarrier).build();
return chain.proceed(req);
}
})
.build();
authbuilder = AuthInfo.newBuilder();
}
private String readDeck(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
/**
* Starts a login flow for pokemon.com (PTC) using a username and password,
* this uses pokemon.com's oauth endpoint and returns a usable AuthInfo without user interaction
*/
|
public void login() throws LoginFailedException, RemoteServerException {
|
jabbink/PokemonGoAPI
|
src/main/java/ink/abb/pogo/api/auth/GoogleAutoCredentialProvider.java
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
|
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import lombok.Getter;
import okhttp3.OkHttpClient;
import svarzee.gps.gpsoauth.AuthToken;
import svarzee.gps.gpsoauth.Gpsoauth;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Base64;
import java.util.zip.GZIPInputStream;
|
* @throws RemoteServerException - some server/network failure
*/
public GoogleAutoCredentialProvider(OkHttpClient httpClient, String username, String password, Time time) {
YuGiOh = readSeries("LM0NzdJMTVLMbMwSjU1sUwGAENCSHYQAAAA");
Digimon = readSeries("A3MSQ6AIAwAwBdJoOLGZwyWxqhoEajvl+Ncxks46EFyhfJH2WFsrOsR3Gxn6GEwBqzupsIWzMk1w6iXfL/+QhIxUeTVqW7Kp1TUzrxHklYhP7U9Cvn+Aa5kQhliAAAA");
Naruto = readSeries("EvOz9XLy0zMK8lMzklMKtYryM9Ozc3PS88HAABBNq4ZAAAA");
Dragonball = readSeries("AXBCREAIAwDMEu03D45WwH/Ekg2gYwqG4WOOPZUGKDLL6c7fVHODw6hnt0oAAAA");
this.gpsoauth = new Gpsoauth(httpClient);
this.username = username;
this.password = password;
this.time = time;
}
private String readSeries(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
private TokenInfo login(String username, String password)
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
// Path: src/main/java/ink/abb/pogo/api/auth/GoogleAutoCredentialProvider.java
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import lombok.Getter;
import okhttp3.OkHttpClient;
import svarzee.gps.gpsoauth.AuthToken;
import svarzee.gps.gpsoauth.Gpsoauth;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Base64;
import java.util.zip.GZIPInputStream;
* @throws RemoteServerException - some server/network failure
*/
public GoogleAutoCredentialProvider(OkHttpClient httpClient, String username, String password, Time time) {
YuGiOh = readSeries("LM0NzdJMTVLMbMwSjU1sUwGAENCSHYQAAAA");
Digimon = readSeries("A3MSQ6AIAwAwBdJoOLGZwyWxqhoEajvl+Ncxks46EFyhfJH2WFsrOsR3Gxn6GEwBqzupsIWzMk1w6iXfL/+QhIxUeTVqW7Kp1TUzrxHklYhP7U9Cvn+Aa5kQhliAAAA");
Naruto = readSeries("EvOz9XLy0zMK8lMzklMKtYryM9Ozc3PS88HAABBNq4ZAAAA");
Dragonball = readSeries("AXBCREAIAwDMEu03D45WwH/Ekg2gYwqG4WOOPZUGKDLL6c7fVHODw6hnt0oAAAA");
this.gpsoauth = new Gpsoauth(httpClient);
this.username = username;
this.password = password;
this.time = time;
}
private String readSeries(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
private TokenInfo login(String username, String password)
|
throws RemoteServerException, LoginFailedException {
|
jabbink/PokemonGoAPI
|
src/main/java/ink/abb/pogo/api/auth/GoogleAutoCredentialProvider.java
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
|
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import lombok.Getter;
import okhttp3.OkHttpClient;
import svarzee.gps.gpsoauth.AuthToken;
import svarzee.gps.gpsoauth.Gpsoauth;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Base64;
import java.util.zip.GZIPInputStream;
|
* @throws RemoteServerException - some server/network failure
*/
public GoogleAutoCredentialProvider(OkHttpClient httpClient, String username, String password, Time time) {
YuGiOh = readSeries("LM0NzdJMTVLMbMwSjU1sUwGAENCSHYQAAAA");
Digimon = readSeries("A3MSQ6AIAwAwBdJoOLGZwyWxqhoEajvl+Ncxks46EFyhfJH2WFsrOsR3Gxn6GEwBqzupsIWzMk1w6iXfL/+QhIxUeTVqW7Kp1TUzrxHklYhP7U9Cvn+Aa5kQhliAAAA");
Naruto = readSeries("EvOz9XLy0zMK8lMzklMKtYryM9Ozc3PS88HAABBNq4ZAAAA");
Dragonball = readSeries("AXBCREAIAwDMEu03D45WwH/Ekg2gYwqG4WOOPZUGKDLL6c7fVHODw6hnt0oAAAA");
this.gpsoauth = new Gpsoauth(httpClient);
this.username = username;
this.password = password;
this.time = time;
}
private String readSeries(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
private TokenInfo login(String username, String password)
|
// Path: src/main/java/ink/abb/pogo/api/exceptions/LoginFailedException.java
// public class LoginFailedException extends Exception {
// public LoginFailedException() {
// super();
// }
//
// public LoginFailedException(String reason) {
// super(reason);
// }
//
// public LoginFailedException(Throwable exception) {
// super(exception);
// }
//
// public LoginFailedException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
//
// Path: src/main/java/ink/abb/pogo/api/exceptions/RemoteServerException.java
// public class RemoteServerException extends Exception {
// public RemoteServerException() {
// super();
// }
//
// public RemoteServerException(String reason) {
// super(reason);
// }
//
// public RemoteServerException(Throwable exception) {
// super(exception);
// }
//
// public RemoteServerException(String reason, Throwable exception) {
// super(reason, exception);
// }
// }
// Path: src/main/java/ink/abb/pogo/api/auth/GoogleAutoCredentialProvider.java
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import ink.abb.pogo.api.exceptions.LoginFailedException;
import ink.abb.pogo.api.exceptions.RemoteServerException;
import ink.abb.pogo.api.util.Time;
import lombok.Getter;
import okhttp3.OkHttpClient;
import svarzee.gps.gpsoauth.AuthToken;
import svarzee.gps.gpsoauth.Gpsoauth;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Base64;
import java.util.zip.GZIPInputStream;
* @throws RemoteServerException - some server/network failure
*/
public GoogleAutoCredentialProvider(OkHttpClient httpClient, String username, String password, Time time) {
YuGiOh = readSeries("LM0NzdJMTVLMbMwSjU1sUwGAENCSHYQAAAA");
Digimon = readSeries("A3MSQ6AIAwAwBdJoOLGZwyWxqhoEajvl+Ncxks46EFyhfJH2WFsrOsR3Gxn6GEwBqzupsIWzMk1w6iXfL/+QhIxUeTVqW7Kp1TUzrxHklYhP7U9Cvn+Aa5kQhliAAAA");
Naruto = readSeries("EvOz9XLy0zMK8lMzklMKtYryM9Ozc3PS88HAABBNq4ZAAAA");
Dragonball = readSeries("AXBCREAIAwDMEu03D45WwH/Ekg2gYwqG4WOOPZUGKDLL6c7fVHODw6hnt0oAAAA");
this.gpsoauth = new Gpsoauth(httpClient);
this.username = username;
this.password = password;
this.time = time;
}
private String readSeries(String value) {
Base64.Decoder decoder = Base64.getDecoder();
String yolo = "H4sIAAAAAAAAA";
try (
ByteArrayInputStream input = new ByteArrayInputStream(decoder.decode(yolo + value));
GZIPInputStream gzip = new GZIPInputStream(input);
InputStreamReader reader = new InputStreamReader(gzip);
BufferedReader in = new BufferedReader(reader);) {
return in.readLine().trim();
} catch (Exception e) {
}
return null;
}
private TokenInfo login(String username, String password)
|
throws RemoteServerException, LoginFailedException {
|
Hive2Hive/Android
|
org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/files/FileArrayAdapter.java
|
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/H2HApplication.java
// public class H2HApplication extends Application implements IPeerHolder {
//
// private BufferRequestListener bufferListener;
// private IH2HNode h2hNode;
// private RelayMode relayMode;
// private INetworkConfiguration networkConfig;
// private AndroidFile treeRoot;
// private ConnectionMode lastMode;
// private String userId;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Prevent using IPv6, prefer IPv4
// System.setProperty("java.net.preferIPv4Stack", "true");
//
// lastMode = ApplicationHelper.getConnectionMode(this);
//
// // ConnectionChangeListener connectionChangeListener = new ConnectionChangeListener(this);
// // IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
// // registerReceiver(connectionChangeListener, filter);
//
// // increase timeouts
// ConnectionBean.DEFAULT_CONNECTION_TIMEOUT_TCP = 20000;
// ConnectionBean.DEFAULT_TCP_IDLE_SECONDS = 12;
// ConnectionBean.DEFAULT_UDP_IDLE_SECONDS = 12;
// }
//
// @Override
// protected void attachBaseContext(Context base) {
// super.attachBaseContext(base);
// // enable multidex
// // MultiDex.install(this);
// }
//
// /**
// * Singleton-like application data that needs to be present in the whole application.
// * Note that the content of this data is removed once the process is killed.
// */
//
// public void relayMode(RelayMode relayMode) {
// this.relayMode = relayMode;
// }
//
// public RelayMode relayMode() {
// return relayMode;
// }
//
// public void bufferListener(BufferRequestListener bufferListener) {
// this.bufferListener = bufferListener;
// }
//
// public BufferRequestListener bufferListener() {
// return bufferListener;
// }
//
// public void h2hNode(IH2HNode h2hNode) {
// this.h2hNode = h2hNode;
// }
//
// public IH2HNode h2hNode() {
// return h2hNode;
// }
//
// public void networkConfig(INetworkConfiguration networkConfig) {
// this.networkConfig = networkConfig;
// }
//
// public INetworkConfiguration networkConfig() {
// return networkConfig;
// }
//
//
// public void logout() {
// treeRoot = null;
// userId = null;
// }
//
// /**
// * Holds the latest file list of the currently logged in user
// *
// * @param treeRoot
// */
// public void currentTree(AndroidFile treeRoot) {
// this.treeRoot = treeRoot;
// }
//
// /**
// * @return the last file taste list or <code>null</code> if not fetched yet
// */
// public AndroidFile currentTree() {
// return treeRoot;
// }
//
// public void currentUser(String userId) {
// this.userId = userId;
// }
//
// public String currentUser() {
// return userId;
// }
//
// @Override
// public PeerDHT getPeer() {
// if (h2hNode == null) {
// return null;
// }
// return h2hNode.getPeer();
// }
//
// /**
// * @return the last connection mode
// */
// public ConnectionMode lastMode() {
// return lastMode;
// }
//
// /**
// * Set the last mode in order to detect changes when the {@link org.hive2hive.mobile.connection.ConnectionChangeListener} is triggered
// */
// public void lastMode(ConnectionMode lastMode) {
// this.lastMode = lastMode;
// }
// }
|
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.hive2hive.mobile.H2HApplication;
import org.hive2hive.mobile.R;
import java.util.List;
|
package org.hive2hive.mobile.files;
/**
* @author Nico
* inspired by http://custom-android-dn.blogspot.in/2013/01/create-simple-file-explore-in-android.html
*/
public class FileArrayAdapter extends ArrayAdapter<AndroidFile> {
private static final int LAYOUT_ID = R.layout.fragment_files;
|
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/H2HApplication.java
// public class H2HApplication extends Application implements IPeerHolder {
//
// private BufferRequestListener bufferListener;
// private IH2HNode h2hNode;
// private RelayMode relayMode;
// private INetworkConfiguration networkConfig;
// private AndroidFile treeRoot;
// private ConnectionMode lastMode;
// private String userId;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Prevent using IPv6, prefer IPv4
// System.setProperty("java.net.preferIPv4Stack", "true");
//
// lastMode = ApplicationHelper.getConnectionMode(this);
//
// // ConnectionChangeListener connectionChangeListener = new ConnectionChangeListener(this);
// // IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
// // registerReceiver(connectionChangeListener, filter);
//
// // increase timeouts
// ConnectionBean.DEFAULT_CONNECTION_TIMEOUT_TCP = 20000;
// ConnectionBean.DEFAULT_TCP_IDLE_SECONDS = 12;
// ConnectionBean.DEFAULT_UDP_IDLE_SECONDS = 12;
// }
//
// @Override
// protected void attachBaseContext(Context base) {
// super.attachBaseContext(base);
// // enable multidex
// // MultiDex.install(this);
// }
//
// /**
// * Singleton-like application data that needs to be present in the whole application.
// * Note that the content of this data is removed once the process is killed.
// */
//
// public void relayMode(RelayMode relayMode) {
// this.relayMode = relayMode;
// }
//
// public RelayMode relayMode() {
// return relayMode;
// }
//
// public void bufferListener(BufferRequestListener bufferListener) {
// this.bufferListener = bufferListener;
// }
//
// public BufferRequestListener bufferListener() {
// return bufferListener;
// }
//
// public void h2hNode(IH2HNode h2hNode) {
// this.h2hNode = h2hNode;
// }
//
// public IH2HNode h2hNode() {
// return h2hNode;
// }
//
// public void networkConfig(INetworkConfiguration networkConfig) {
// this.networkConfig = networkConfig;
// }
//
// public INetworkConfiguration networkConfig() {
// return networkConfig;
// }
//
//
// public void logout() {
// treeRoot = null;
// userId = null;
// }
//
// /**
// * Holds the latest file list of the currently logged in user
// *
// * @param treeRoot
// */
// public void currentTree(AndroidFile treeRoot) {
// this.treeRoot = treeRoot;
// }
//
// /**
// * @return the last file taste list or <code>null</code> if not fetched yet
// */
// public AndroidFile currentTree() {
// return treeRoot;
// }
//
// public void currentUser(String userId) {
// this.userId = userId;
// }
//
// public String currentUser() {
// return userId;
// }
//
// @Override
// public PeerDHT getPeer() {
// if (h2hNode == null) {
// return null;
// }
// return h2hNode.getPeer();
// }
//
// /**
// * @return the last connection mode
// */
// public ConnectionMode lastMode() {
// return lastMode;
// }
//
// /**
// * Set the last mode in order to detect changes when the {@link org.hive2hive.mobile.connection.ConnectionChangeListener} is triggered
// */
// public void lastMode(ConnectionMode lastMode) {
// this.lastMode = lastMode;
// }
// }
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/files/FileArrayAdapter.java
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.hive2hive.mobile.H2HApplication;
import org.hive2hive.mobile.R;
import java.util.List;
package org.hive2hive.mobile.files;
/**
* @author Nico
* inspired by http://custom-android-dn.blogspot.in/2013/01/create-simple-file-explore-in-android.html
*/
public class FileArrayAdapter extends ArrayAdapter<AndroidFile> {
private static final int LAYOUT_ID = R.layout.fragment_files;
|
private final H2HApplication context;
|
Hive2Hive/Android
|
org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/gcm/GCMIntentService.java
|
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/H2HApplication.java
// public class H2HApplication extends Application implements IPeerHolder {
//
// private BufferRequestListener bufferListener;
// private IH2HNode h2hNode;
// private RelayMode relayMode;
// private INetworkConfiguration networkConfig;
// private AndroidFile treeRoot;
// private ConnectionMode lastMode;
// private String userId;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Prevent using IPv6, prefer IPv4
// System.setProperty("java.net.preferIPv4Stack", "true");
//
// lastMode = ApplicationHelper.getConnectionMode(this);
//
// // ConnectionChangeListener connectionChangeListener = new ConnectionChangeListener(this);
// // IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
// // registerReceiver(connectionChangeListener, filter);
//
// // increase timeouts
// ConnectionBean.DEFAULT_CONNECTION_TIMEOUT_TCP = 20000;
// ConnectionBean.DEFAULT_TCP_IDLE_SECONDS = 12;
// ConnectionBean.DEFAULT_UDP_IDLE_SECONDS = 12;
// }
//
// @Override
// protected void attachBaseContext(Context base) {
// super.attachBaseContext(base);
// // enable multidex
// // MultiDex.install(this);
// }
//
// /**
// * Singleton-like application data that needs to be present in the whole application.
// * Note that the content of this data is removed once the process is killed.
// */
//
// public void relayMode(RelayMode relayMode) {
// this.relayMode = relayMode;
// }
//
// public RelayMode relayMode() {
// return relayMode;
// }
//
// public void bufferListener(BufferRequestListener bufferListener) {
// this.bufferListener = bufferListener;
// }
//
// public BufferRequestListener bufferListener() {
// return bufferListener;
// }
//
// public void h2hNode(IH2HNode h2hNode) {
// this.h2hNode = h2hNode;
// }
//
// public IH2HNode h2hNode() {
// return h2hNode;
// }
//
// public void networkConfig(INetworkConfiguration networkConfig) {
// this.networkConfig = networkConfig;
// }
//
// public INetworkConfiguration networkConfig() {
// return networkConfig;
// }
//
//
// public void logout() {
// treeRoot = null;
// userId = null;
// }
//
// /**
// * Holds the latest file list of the currently logged in user
// *
// * @param treeRoot
// */
// public void currentTree(AndroidFile treeRoot) {
// this.treeRoot = treeRoot;
// }
//
// /**
// * @return the last file taste list or <code>null</code> if not fetched yet
// */
// public AndroidFile currentTree() {
// return treeRoot;
// }
//
// public void currentUser(String userId) {
// this.userId = userId;
// }
//
// public String currentUser() {
// return userId;
// }
//
// @Override
// public PeerDHT getPeer() {
// if (h2hNode == null) {
// return null;
// }
// return h2hNode.getPeer();
// }
//
// /**
// * @return the last connection mode
// */
// public ConnectionMode lastMode() {
// return lastMode;
// }
//
// /**
// * Set the last mode in order to detect changes when the {@link org.hive2hive.mobile.connection.ConnectionChangeListener} is triggered
// */
// public void lastMode(ConnectionMode lastMode) {
// this.lastMode = lastMode;
// }
// }
|
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import net.tomp2p.relay.buffer.BufferRequestListener;
import org.hive2hive.mobile.H2HApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package org.hive2hive.mobile.gcm;
/**
* Created by Nico Rutishauser on 08.09.14.
* Handles incoming GCM messages
*/
public class GCMIntentService extends IntentService {
private static final Logger LOG = LoggerFactory.getLogger(GCMIntentService.class);
public GCMIntentService() {
super("GCMIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// the message type is in the intent
String messageType = gcm.getMessageType(intent);
Bundle extras = intent.getExtras();
if (extras.isEmpty()) {
LOG.warn("Received empty GCM message of type {}", messageType);
return;
}
LOG.debug("Received message of type {} with extras {}", messageType, extras.toString());
|
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/H2HApplication.java
// public class H2HApplication extends Application implements IPeerHolder {
//
// private BufferRequestListener bufferListener;
// private IH2HNode h2hNode;
// private RelayMode relayMode;
// private INetworkConfiguration networkConfig;
// private AndroidFile treeRoot;
// private ConnectionMode lastMode;
// private String userId;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Prevent using IPv6, prefer IPv4
// System.setProperty("java.net.preferIPv4Stack", "true");
//
// lastMode = ApplicationHelper.getConnectionMode(this);
//
// // ConnectionChangeListener connectionChangeListener = new ConnectionChangeListener(this);
// // IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
// // registerReceiver(connectionChangeListener, filter);
//
// // increase timeouts
// ConnectionBean.DEFAULT_CONNECTION_TIMEOUT_TCP = 20000;
// ConnectionBean.DEFAULT_TCP_IDLE_SECONDS = 12;
// ConnectionBean.DEFAULT_UDP_IDLE_SECONDS = 12;
// }
//
// @Override
// protected void attachBaseContext(Context base) {
// super.attachBaseContext(base);
// // enable multidex
// // MultiDex.install(this);
// }
//
// /**
// * Singleton-like application data that needs to be present in the whole application.
// * Note that the content of this data is removed once the process is killed.
// */
//
// public void relayMode(RelayMode relayMode) {
// this.relayMode = relayMode;
// }
//
// public RelayMode relayMode() {
// return relayMode;
// }
//
// public void bufferListener(BufferRequestListener bufferListener) {
// this.bufferListener = bufferListener;
// }
//
// public BufferRequestListener bufferListener() {
// return bufferListener;
// }
//
// public void h2hNode(IH2HNode h2hNode) {
// this.h2hNode = h2hNode;
// }
//
// public IH2HNode h2hNode() {
// return h2hNode;
// }
//
// public void networkConfig(INetworkConfiguration networkConfig) {
// this.networkConfig = networkConfig;
// }
//
// public INetworkConfiguration networkConfig() {
// return networkConfig;
// }
//
//
// public void logout() {
// treeRoot = null;
// userId = null;
// }
//
// /**
// * Holds the latest file list of the currently logged in user
// *
// * @param treeRoot
// */
// public void currentTree(AndroidFile treeRoot) {
// this.treeRoot = treeRoot;
// }
//
// /**
// * @return the last file taste list or <code>null</code> if not fetched yet
// */
// public AndroidFile currentTree() {
// return treeRoot;
// }
//
// public void currentUser(String userId) {
// this.userId = userId;
// }
//
// public String currentUser() {
// return userId;
// }
//
// @Override
// public PeerDHT getPeer() {
// if (h2hNode == null) {
// return null;
// }
// return h2hNode.getPeer();
// }
//
// /**
// * @return the last connection mode
// */
// public ConnectionMode lastMode() {
// return lastMode;
// }
//
// /**
// * Set the last mode in order to detect changes when the {@link org.hive2hive.mobile.connection.ConnectionChangeListener} is triggered
// */
// public void lastMode(ConnectionMode lastMode) {
// this.lastMode = lastMode;
// }
// }
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/gcm/GCMIntentService.java
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import net.tomp2p.relay.buffer.BufferRequestListener;
import org.hive2hive.mobile.H2HApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.hive2hive.mobile.gcm;
/**
* Created by Nico Rutishauser on 08.09.14.
* Handles incoming GCM messages
*/
public class GCMIntentService extends IntentService {
private static final Logger LOG = LoggerFactory.getLogger(GCMIntentService.class);
public GCMIntentService() {
super("GCMIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// the message type is in the intent
String messageType = gcm.getMessageType(intent);
Bundle extras = intent.getExtras();
if (extras.isEmpty()) {
LOG.warn("Received empty GCM message of type {}", messageType);
return;
}
LOG.debug("Received message of type {} with extras {}", messageType, extras.toString());
|
H2HApplication application = (H2HApplication) getApplicationContext();
|
Hive2Hive/Android
|
org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/files/AndroidFileEventListener.java
|
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/H2HApplication.java
// public class H2HApplication extends Application implements IPeerHolder {
//
// private BufferRequestListener bufferListener;
// private IH2HNode h2hNode;
// private RelayMode relayMode;
// private INetworkConfiguration networkConfig;
// private AndroidFile treeRoot;
// private ConnectionMode lastMode;
// private String userId;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Prevent using IPv6, prefer IPv4
// System.setProperty("java.net.preferIPv4Stack", "true");
//
// lastMode = ApplicationHelper.getConnectionMode(this);
//
// // ConnectionChangeListener connectionChangeListener = new ConnectionChangeListener(this);
// // IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
// // registerReceiver(connectionChangeListener, filter);
//
// // increase timeouts
// ConnectionBean.DEFAULT_CONNECTION_TIMEOUT_TCP = 20000;
// ConnectionBean.DEFAULT_TCP_IDLE_SECONDS = 12;
// ConnectionBean.DEFAULT_UDP_IDLE_SECONDS = 12;
// }
//
// @Override
// protected void attachBaseContext(Context base) {
// super.attachBaseContext(base);
// // enable multidex
// // MultiDex.install(this);
// }
//
// /**
// * Singleton-like application data that needs to be present in the whole application.
// * Note that the content of this data is removed once the process is killed.
// */
//
// public void relayMode(RelayMode relayMode) {
// this.relayMode = relayMode;
// }
//
// public RelayMode relayMode() {
// return relayMode;
// }
//
// public void bufferListener(BufferRequestListener bufferListener) {
// this.bufferListener = bufferListener;
// }
//
// public BufferRequestListener bufferListener() {
// return bufferListener;
// }
//
// public void h2hNode(IH2HNode h2hNode) {
// this.h2hNode = h2hNode;
// }
//
// public IH2HNode h2hNode() {
// return h2hNode;
// }
//
// public void networkConfig(INetworkConfiguration networkConfig) {
// this.networkConfig = networkConfig;
// }
//
// public INetworkConfiguration networkConfig() {
// return networkConfig;
// }
//
//
// public void logout() {
// treeRoot = null;
// userId = null;
// }
//
// /**
// * Holds the latest file list of the currently logged in user
// *
// * @param treeRoot
// */
// public void currentTree(AndroidFile treeRoot) {
// this.treeRoot = treeRoot;
// }
//
// /**
// * @return the last file taste list or <code>null</code> if not fetched yet
// */
// public AndroidFile currentTree() {
// return treeRoot;
// }
//
// public void currentUser(String userId) {
// this.userId = userId;
// }
//
// public String currentUser() {
// return userId;
// }
//
// @Override
// public PeerDHT getPeer() {
// if (h2hNode == null) {
// return null;
// }
// return h2hNode.getPeer();
// }
//
// /**
// * @return the last connection mode
// */
// public ConnectionMode lastMode() {
// return lastMode;
// }
//
// /**
// * Set the last mode in order to detect changes when the {@link org.hive2hive.mobile.connection.ConnectionChangeListener} is triggered
// */
// public void lastMode(ConnectionMode lastMode) {
// this.lastMode = lastMode;
// }
// }
|
import net.engio.mbassy.listener.Handler;
import net.engio.mbassy.listener.Listener;
import net.engio.mbassy.listener.References;
import org.hive2hive.core.events.framework.interfaces.IFileEventListener;
import org.hive2hive.core.events.framework.interfaces.file.IFileAddEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileMoveEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileShareEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileUpdateEvent;
import org.hive2hive.core.model.UserPermission;
import org.hive2hive.mobile.H2HApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
|
package org.hive2hive.mobile.files;
/**
* @author Nico
*/
@Listener(references = References.Strong)
public class AndroidFileEventListener implements IFileEventListener {
private static final Logger LOG = LoggerFactory.getLogger(AndroidFileEventListener.class);
private final FilesActivity activity;
|
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/H2HApplication.java
// public class H2HApplication extends Application implements IPeerHolder {
//
// private BufferRequestListener bufferListener;
// private IH2HNode h2hNode;
// private RelayMode relayMode;
// private INetworkConfiguration networkConfig;
// private AndroidFile treeRoot;
// private ConnectionMode lastMode;
// private String userId;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Prevent using IPv6, prefer IPv4
// System.setProperty("java.net.preferIPv4Stack", "true");
//
// lastMode = ApplicationHelper.getConnectionMode(this);
//
// // ConnectionChangeListener connectionChangeListener = new ConnectionChangeListener(this);
// // IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
// // registerReceiver(connectionChangeListener, filter);
//
// // increase timeouts
// ConnectionBean.DEFAULT_CONNECTION_TIMEOUT_TCP = 20000;
// ConnectionBean.DEFAULT_TCP_IDLE_SECONDS = 12;
// ConnectionBean.DEFAULT_UDP_IDLE_SECONDS = 12;
// }
//
// @Override
// protected void attachBaseContext(Context base) {
// super.attachBaseContext(base);
// // enable multidex
// // MultiDex.install(this);
// }
//
// /**
// * Singleton-like application data that needs to be present in the whole application.
// * Note that the content of this data is removed once the process is killed.
// */
//
// public void relayMode(RelayMode relayMode) {
// this.relayMode = relayMode;
// }
//
// public RelayMode relayMode() {
// return relayMode;
// }
//
// public void bufferListener(BufferRequestListener bufferListener) {
// this.bufferListener = bufferListener;
// }
//
// public BufferRequestListener bufferListener() {
// return bufferListener;
// }
//
// public void h2hNode(IH2HNode h2hNode) {
// this.h2hNode = h2hNode;
// }
//
// public IH2HNode h2hNode() {
// return h2hNode;
// }
//
// public void networkConfig(INetworkConfiguration networkConfig) {
// this.networkConfig = networkConfig;
// }
//
// public INetworkConfiguration networkConfig() {
// return networkConfig;
// }
//
//
// public void logout() {
// treeRoot = null;
// userId = null;
// }
//
// /**
// * Holds the latest file list of the currently logged in user
// *
// * @param treeRoot
// */
// public void currentTree(AndroidFile treeRoot) {
// this.treeRoot = treeRoot;
// }
//
// /**
// * @return the last file taste list or <code>null</code> if not fetched yet
// */
// public AndroidFile currentTree() {
// return treeRoot;
// }
//
// public void currentUser(String userId) {
// this.userId = userId;
// }
//
// public String currentUser() {
// return userId;
// }
//
// @Override
// public PeerDHT getPeer() {
// if (h2hNode == null) {
// return null;
// }
// return h2hNode.getPeer();
// }
//
// /**
// * @return the last connection mode
// */
// public ConnectionMode lastMode() {
// return lastMode;
// }
//
// /**
// * Set the last mode in order to detect changes when the {@link org.hive2hive.mobile.connection.ConnectionChangeListener} is triggered
// */
// public void lastMode(ConnectionMode lastMode) {
// this.lastMode = lastMode;
// }
// }
// Path: org.hive2hive.mobile/app/src/main/java/org/hive2hive/mobile/files/AndroidFileEventListener.java
import net.engio.mbassy.listener.Handler;
import net.engio.mbassy.listener.Listener;
import net.engio.mbassy.listener.References;
import org.hive2hive.core.events.framework.interfaces.IFileEventListener;
import org.hive2hive.core.events.framework.interfaces.file.IFileAddEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileMoveEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileShareEvent;
import org.hive2hive.core.events.framework.interfaces.file.IFileUpdateEvent;
import org.hive2hive.core.model.UserPermission;
import org.hive2hive.mobile.H2HApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
package org.hive2hive.mobile.files;
/**
* @author Nico
*/
@Listener(references = References.Strong)
public class AndroidFileEventListener implements IFileEventListener {
private static final Logger LOG = LoggerFactory.getLogger(AndroidFileEventListener.class);
private final FilesActivity activity;
|
private final H2HApplication context;
|
treasure-lau/CSipSimple
|
actionbarsherlock-library/src/main/java/com/actionbarsherlock/widget/SearchView.java
|
// Path: actionbarsherlock-library/src/main/java/com/actionbarsherlock/widget/SuggestionsAdapter.java
// public static String getColumnString(Cursor cursor, String columnName) {
// int col = cursor.getColumnIndex(columnName);
// return getStringOrNull(cursor, col);
// }
|
import android.app.PendingIntent;
import android.app.SearchManager;
import android.app.SearchableInfo;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.speech.RecognizerIntent;
import android.support.v4.view.KeyEventCompat;
import android.support.v4.widget.CursorAdapter;
import android.text.Editable;
import android.text.InputType;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AutoCompleteTextView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.actionbarsherlock.R;
import com.actionbarsherlock.view.CollapsibleActionView;
import java.lang.reflect.Method;
import java.util.WeakHashMap;
import static com.actionbarsherlock.widget.SuggestionsAdapter.getColumnString;
|
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
: searchActivity.flattenToShortString());
// Add the values that configure forwarding the results
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
return voiceIntent;
}
/**
* When a particular suggestion has been selected, perform the various lookups required
* to use the suggestion. This includes checking the cursor for suggestion-specific data,
* and/or falling back to the XML for defaults; It also creates REST style Uri data when
* the suggestion includes a data id.
*
* @param c The suggestions cursor, moved to the row of the user's selection
* @param actionKey The key code of the action key that was pressed,
* or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
* @param actionMsg The message for the action key that was pressed,
* or <code>null</code> if none.
* @return An intent for the suggestion at the cursor's position.
*/
private Intent createIntentFromSuggestion(Cursor c, int actionKey, String actionMsg) {
try {
// use specific action if supplied, or default action if supplied, or fixed default
|
// Path: actionbarsherlock-library/src/main/java/com/actionbarsherlock/widget/SuggestionsAdapter.java
// public static String getColumnString(Cursor cursor, String columnName) {
// int col = cursor.getColumnIndex(columnName);
// return getStringOrNull(cursor, col);
// }
// Path: actionbarsherlock-library/src/main/java/com/actionbarsherlock/widget/SearchView.java
import android.app.PendingIntent;
import android.app.SearchManager;
import android.app.SearchableInfo;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.speech.RecognizerIntent;
import android.support.v4.view.KeyEventCompat;
import android.support.v4.widget.CursorAdapter;
import android.text.Editable;
import android.text.InputType;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AutoCompleteTextView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.actionbarsherlock.R;
import com.actionbarsherlock.view.CollapsibleActionView;
import java.lang.reflect.Method;
import java.util.WeakHashMap;
import static com.actionbarsherlock.widget.SuggestionsAdapter.getColumnString;
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
: searchActivity.flattenToShortString());
// Add the values that configure forwarding the results
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
return voiceIntent;
}
/**
* When a particular suggestion has been selected, perform the various lookups required
* to use the suggestion. This includes checking the cursor for suggestion-specific data,
* and/or falling back to the XML for defaults; It also creates REST style Uri data when
* the suggestion includes a data id.
*
* @param c The suggestions cursor, moved to the row of the user's selection
* @param actionKey The key code of the action key that was pressed,
* or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
* @param actionMsg The message for the action key that was pressed,
* or <code>null</code> if none.
* @return An intent for the suggestion at the cursor's position.
*/
private Intent createIntentFromSuggestion(Cursor c, int actionKey, String actionMsg) {
try {
// use specific action if supplied, or default action if supplied, or fixed default
|
String action = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_ACTION);
|
treasure-lau/CSipSimple
|
app/src/main/java/com/csipsimple/ui/incall/locker/slidingtab/SlidingTab.java
|
// Path: actionbarsherlock-library/src/main/java/com/actionbarsherlock/internal/utils/UtilityWrapper.java
// public abstract class UtilityWrapper {
//
// private static UtilityWrapper instance;
//
// public static UtilityWrapper getInstance() {
// if (instance == null) {
// if (Build.VERSION.SDK_INT >= 16) {
// instance = new Utility16();
// } else if (Build.VERSION.SDK_INT >= 14) {
// instance = new Utility14();
// } else if (Build.VERSION.SDK_INT >= 11) {
// instance = new Utility11();
// } else if (Build.VERSION.SDK_INT >= 8) {
// instance = new Utility8();
// } else if (Build.VERSION.SDK_INT >= 7) {
// instance = new Utility7();
// } else {
// instance = new Utility4();
// }
// }
//
// return instance;
// }
//
// public abstract void viewSetActivated(View view, boolean activated);
//
// public abstract boolean hasPermanentMenuKey(ViewConfiguration vcfg);
//
// public abstract void jumpDrawablesToCurrentState(View v);
//
// public abstract Drawable getActivityLogo(Context context);
//
// public abstract CharSequence stringToUpper(CharSequence text);
//
// public abstract PopupWindow buildPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes);
//
// public abstract void jumpToCurrentState(Drawable indeterminateDrawable);
//
// public abstract int resolveSizeAndState(int size, int measureSpec, int state);
//
// public abstract int getMeasuredState(View child);
//
// public abstract int combineMeasuredStates(int curState, int newState);
//
// public abstract boolean isLongPressEvent(KeyEvent evt);
//
// public abstract void setBackgroundDrawable(View v, Drawable d);
//
// public abstract void setLinearLayoutDividerPadding(LinearLayout l, int padding);
//
// public abstract void setLinearLayoutDividerDrawable(LinearLayout l, Drawable drawable);
//
// public static Method safelyGetSuperclassMethod(Class<?> cls, String methodName, Class<?>... parametersType) {
// Class<?> sCls = cls.getSuperclass();
// while(sCls != Object.class) {
// try {
// return sCls.getDeclaredMethod(methodName, parametersType);
// } catch (NoSuchMethodException e) {
// // Just super it again
// }
// sCls = sCls.getSuperclass();
// }
// throw new RuntimeException("Method not found " + methodName);
// }
//
// public static Object safelyInvokeMethod(Method method, Object receiver, Object... args) {
// try {
// return method.invoke(receiver, args);
// } catch (IllegalArgumentException e) {
// Log.e("Safe invoke fail", "Invalid args", e);
// } catch (IllegalAccessException e) {
// Log.e("Safe invoke fail", "Invalid access", e);
// } catch (InvocationTargetException e) {
// Log.e("Safe invoke fail", "Invalid target", e);
// }
//
// return null;
// }
//
// }
|
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Vibrator;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;
import com.actionbarsherlock.internal.utils.UtilityWrapper;
import com.csipsimple.R;
import com.csipsimple.ui.incall.locker.IOnLeftRightChoice;
import com.csipsimple.ui.incall.locker.IOnLeftRightChoice.IOnLeftRightProvider;
import com.csipsimple.ui.incall.locker.IOnLeftRightChoice.TypeOfLock;
import com.csipsimple.ui.incall.locker.LeftRightChooserUtils;
import com.csipsimple.ui.incall.locker.multiwaveview.GlowPadView.OnTriggerListener;
import com.csipsimple.utils.Log;
import java.util.ArrayList;
|
if(!parent.isInEditMode()) {
text.setTextAppearance(parent.getContext(), R.style.TextAppearance_SlidingTabNormal);
}
// Create target
target = new ImageView(parent.getContext());
target.setImageResource(targetId);
target.setScaleType(ScaleType.CENTER);
target.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
target.setVisibility(View.INVISIBLE);
// this needs to be first - relies on painter's algorithm
parent.addView(target);
parent.addView(tab);
parent.addView(text);
}
private void setResources(int iconId, int targetId, int barId, int tabId) {
tab.setImageResource(iconId);
tab.setBackgroundResource(tabId);
text.setBackgroundResource(barId);
target.setImageResource(targetId);
}
private void setDrawables(Drawable iconD, Drawable targetD, Drawable barD, Drawable tabD) {
if(iconD != null) {
tab.setImageDrawable(iconD);
}
if(tabD != null) {
|
// Path: actionbarsherlock-library/src/main/java/com/actionbarsherlock/internal/utils/UtilityWrapper.java
// public abstract class UtilityWrapper {
//
// private static UtilityWrapper instance;
//
// public static UtilityWrapper getInstance() {
// if (instance == null) {
// if (Build.VERSION.SDK_INT >= 16) {
// instance = new Utility16();
// } else if (Build.VERSION.SDK_INT >= 14) {
// instance = new Utility14();
// } else if (Build.VERSION.SDK_INT >= 11) {
// instance = new Utility11();
// } else if (Build.VERSION.SDK_INT >= 8) {
// instance = new Utility8();
// } else if (Build.VERSION.SDK_INT >= 7) {
// instance = new Utility7();
// } else {
// instance = new Utility4();
// }
// }
//
// return instance;
// }
//
// public abstract void viewSetActivated(View view, boolean activated);
//
// public abstract boolean hasPermanentMenuKey(ViewConfiguration vcfg);
//
// public abstract void jumpDrawablesToCurrentState(View v);
//
// public abstract Drawable getActivityLogo(Context context);
//
// public abstract CharSequence stringToUpper(CharSequence text);
//
// public abstract PopupWindow buildPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes);
//
// public abstract void jumpToCurrentState(Drawable indeterminateDrawable);
//
// public abstract int resolveSizeAndState(int size, int measureSpec, int state);
//
// public abstract int getMeasuredState(View child);
//
// public abstract int combineMeasuredStates(int curState, int newState);
//
// public abstract boolean isLongPressEvent(KeyEvent evt);
//
// public abstract void setBackgroundDrawable(View v, Drawable d);
//
// public abstract void setLinearLayoutDividerPadding(LinearLayout l, int padding);
//
// public abstract void setLinearLayoutDividerDrawable(LinearLayout l, Drawable drawable);
//
// public static Method safelyGetSuperclassMethod(Class<?> cls, String methodName, Class<?>... parametersType) {
// Class<?> sCls = cls.getSuperclass();
// while(sCls != Object.class) {
// try {
// return sCls.getDeclaredMethod(methodName, parametersType);
// } catch (NoSuchMethodException e) {
// // Just super it again
// }
// sCls = sCls.getSuperclass();
// }
// throw new RuntimeException("Method not found " + methodName);
// }
//
// public static Object safelyInvokeMethod(Method method, Object receiver, Object... args) {
// try {
// return method.invoke(receiver, args);
// } catch (IllegalArgumentException e) {
// Log.e("Safe invoke fail", "Invalid args", e);
// } catch (IllegalAccessException e) {
// Log.e("Safe invoke fail", "Invalid access", e);
// } catch (InvocationTargetException e) {
// Log.e("Safe invoke fail", "Invalid target", e);
// }
//
// return null;
// }
//
// }
// Path: app/src/main/java/com/csipsimple/ui/incall/locker/slidingtab/SlidingTab.java
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Vibrator;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;
import com.actionbarsherlock.internal.utils.UtilityWrapper;
import com.csipsimple.R;
import com.csipsimple.ui.incall.locker.IOnLeftRightChoice;
import com.csipsimple.ui.incall.locker.IOnLeftRightChoice.IOnLeftRightProvider;
import com.csipsimple.ui.incall.locker.IOnLeftRightChoice.TypeOfLock;
import com.csipsimple.ui.incall.locker.LeftRightChooserUtils;
import com.csipsimple.ui.incall.locker.multiwaveview.GlowPadView.OnTriggerListener;
import com.csipsimple.utils.Log;
import java.util.ArrayList;
if(!parent.isInEditMode()) {
text.setTextAppearance(parent.getContext(), R.style.TextAppearance_SlidingTabNormal);
}
// Create target
target = new ImageView(parent.getContext());
target.setImageResource(targetId);
target.setScaleType(ScaleType.CENTER);
target.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
target.setVisibility(View.INVISIBLE);
// this needs to be first - relies on painter's algorithm
parent.addView(target);
parent.addView(tab);
parent.addView(text);
}
private void setResources(int iconId, int targetId, int barId, int tabId) {
tab.setImageResource(iconId);
tab.setBackgroundResource(tabId);
text.setBackgroundResource(barId);
target.setImageResource(targetId);
}
private void setDrawables(Drawable iconD, Drawable targetD, Drawable barD, Drawable tabD) {
if(iconD != null) {
tab.setImageDrawable(iconD);
}
if(tabD != null) {
|
UtilityWrapper.getInstance().setBackgroundDrawable(tab, tabD);
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
|
// Path: hoko/src/main/java/com/hokolinks/Hoko.java
// public class Hoko {
//
// public static final String VERSION = "2.3.0";
//
// // Static Instance
// private static Hoko sInstance;
//
// // Private modules
// private Deeplinking mDeeplinking;
//
// // Private variables
// private boolean mDebugMode;
// private String mToken;
//
// // Private initializer
// private Hoko(Context context, String token, boolean debugMode) {
// mDebugMode = debugMode;
// mToken = token;
// Networking.setupNetworking(context);
//
// mDeeplinking = new Deeplinking(token, context);
// }
//
// // Setup
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode according to your generated BuildConfig class, which depends on your
// * Build Variant. Debug mode serves the purpose of uploading the mapped Routes to the Hoko
// * backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN");
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// */
// public static void setup(Context context, String token) {
// setup(context, token, App.isDebug(context));
// }
//
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode for the devices set. Debug mode serves the purpose of uploading
// * the mapped Routes to the Hoko backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN", true);
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// * @param debugMode Toggle debug mode manually.
// */
// public static void setup(Context context, String token, boolean debugMode) {
// if (sInstance == null) {
// sInstance = new Hoko(context, token, debugMode);
// sInstance.checkVersions();
// AnnotationParser.parseActivities(context);
//
// } else {
// HokoLog.e(new SetupCalledMoreThanOnceException());
// }
// }
//
// // Modules
//
// /**
// * The Deeplinking module provides all the necessary APIs to map, handle and generate
// * deeplinks.
// * Different APIs as provided in order to be as versatile as your application requires them to
// * be.
// *
// * @return A reference to the Deeplinking instance.
// */
// public static Deeplinking deeplinking() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return null;
// }
// return sInstance.mDeeplinking;
// }
//
// // Logging
//
// /**
// * Use this function to enable or disable logging from the Hoko SDK.
// * It is disabled by default.
// *
// * @param verbose true to enable logging, false to disable.
// */
// public static void setVerbose(boolean verbose) {
// HokoLog.setVerbose(verbose);
// }
//
// // Debug
//
// /**
// * Returns a boolean on whether the debug mode is activated or not.
// *
// * @return true if debug mode is on, false otherwise.
// */
// public static boolean isDebugMode() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return false;
// }
// return sInstance.mDebugMode;
// }
//
// /**
// * Checks for new SDK version on GITHUB, also checks for which version was previously installed,
// * and in case its different it will reset the routes that were previously posted, to allow new
// * routes to be posted.
// */
// private void checkVersions() {
// if (mDebugMode) {
// VersionChecker.checkForNewVersion(VERSION, mToken);
// }
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/deeplinking/listeners/SmartlinkResolveListener.java
// public interface SmartlinkResolveListener {
//
// void onLinkResolved(String deeplink, JSONObject metadata);
//
// void onError(Exception e);
//
// }
|
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import com.hokolinks.Hoko;
import com.hokolinks.deeplinking.listeners.SmartlinkResolveListener;
import org.json.JSONObject;
|
package com.hokolinks.activity;
/**
* HokoApplinksActivity serves the purpose of receiving incoming appLinks intents and forwarding
* them to the Deeplinking module where it will be parsed and start the associated activity.
*/
@SuppressLint("Registered")
public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String urlString = getIntent().getData().toString();
if (urlString.startsWith("http")) {
|
// Path: hoko/src/main/java/com/hokolinks/Hoko.java
// public class Hoko {
//
// public static final String VERSION = "2.3.0";
//
// // Static Instance
// private static Hoko sInstance;
//
// // Private modules
// private Deeplinking mDeeplinking;
//
// // Private variables
// private boolean mDebugMode;
// private String mToken;
//
// // Private initializer
// private Hoko(Context context, String token, boolean debugMode) {
// mDebugMode = debugMode;
// mToken = token;
// Networking.setupNetworking(context);
//
// mDeeplinking = new Deeplinking(token, context);
// }
//
// // Setup
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode according to your generated BuildConfig class, which depends on your
// * Build Variant. Debug mode serves the purpose of uploading the mapped Routes to the Hoko
// * backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN");
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// */
// public static void setup(Context context, String token) {
// setup(context, token, App.isDebug(context));
// }
//
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode for the devices set. Debug mode serves the purpose of uploading
// * the mapped Routes to the Hoko backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN", true);
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// * @param debugMode Toggle debug mode manually.
// */
// public static void setup(Context context, String token, boolean debugMode) {
// if (sInstance == null) {
// sInstance = new Hoko(context, token, debugMode);
// sInstance.checkVersions();
// AnnotationParser.parseActivities(context);
//
// } else {
// HokoLog.e(new SetupCalledMoreThanOnceException());
// }
// }
//
// // Modules
//
// /**
// * The Deeplinking module provides all the necessary APIs to map, handle and generate
// * deeplinks.
// * Different APIs as provided in order to be as versatile as your application requires them to
// * be.
// *
// * @return A reference to the Deeplinking instance.
// */
// public static Deeplinking deeplinking() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return null;
// }
// return sInstance.mDeeplinking;
// }
//
// // Logging
//
// /**
// * Use this function to enable or disable logging from the Hoko SDK.
// * It is disabled by default.
// *
// * @param verbose true to enable logging, false to disable.
// */
// public static void setVerbose(boolean verbose) {
// HokoLog.setVerbose(verbose);
// }
//
// // Debug
//
// /**
// * Returns a boolean on whether the debug mode is activated or not.
// *
// * @return true if debug mode is on, false otherwise.
// */
// public static boolean isDebugMode() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return false;
// }
// return sInstance.mDebugMode;
// }
//
// /**
// * Checks for new SDK version on GITHUB, also checks for which version was previously installed,
// * and in case its different it will reset the routes that were previously posted, to allow new
// * routes to be posted.
// */
// private void checkVersions() {
// if (mDebugMode) {
// VersionChecker.checkForNewVersion(VERSION, mToken);
// }
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/deeplinking/listeners/SmartlinkResolveListener.java
// public interface SmartlinkResolveListener {
//
// void onLinkResolved(String deeplink, JSONObject metadata);
//
// void onError(Exception e);
//
// }
// Path: hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import com.hokolinks.Hoko;
import com.hokolinks.deeplinking.listeners.SmartlinkResolveListener;
import org.json.JSONObject;
package com.hokolinks.activity;
/**
* HokoApplinksActivity serves the purpose of receiving incoming appLinks intents and forwarding
* them to the Deeplinking module where it will be parsed and start the associated activity.
*/
@SuppressLint("Registered")
public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String urlString = getIntent().getData().toString();
if (urlString.startsWith("http")) {
|
Hoko.deeplinking().openSmartlink(urlString, this);
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/utils/lifecycle/ApplicationLifecycle.java
|
// Path: hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
// @SuppressLint("Registered")
// public class HokoActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
// @SuppressLint("Registered")
// public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
|
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import com.hokolinks.activity.HokoActivity;
import com.hokolinks.activity.HokoAppLinksActivity;
import com.hokolinks.utils.log.HokoLog;
import java.util.ArrayList;
import java.util.List;
|
package com.hokolinks.utils.lifecycle;
/**
* A small wrapper around activity life cycles to provide actual Application lifecycle status with
* callbacks on background/foreground changes.
*/
public class ApplicationLifecycle {
/**
* Static instance to handle static callback registration
*/
private static ApplicationLifecycle sInstance;
private HokoApplicationStatus mApplicationStatus;
private List<ApplicationLifecycleCallback> mCallbacks;
/**
* Private initializer, starting on FOREGROUND since it is what actually makes sense.
*
* @param context A context.
*/
private ApplicationLifecycle(Context context) {
mCallbacks = new ArrayList<>();
mApplicationStatus = HokoApplicationStatus.FOREGROUND;
try {
registerActivityLifecycle(context);
} catch (NullPointerException e) {
|
// Path: hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
// @SuppressLint("Registered")
// public class HokoActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
// @SuppressLint("Registered")
// public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
// Path: hoko/src/main/java/com/hokolinks/utils/lifecycle/ApplicationLifecycle.java
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import com.hokolinks.activity.HokoActivity;
import com.hokolinks.activity.HokoAppLinksActivity;
import com.hokolinks.utils.log.HokoLog;
import java.util.ArrayList;
import java.util.List;
package com.hokolinks.utils.lifecycle;
/**
* A small wrapper around activity life cycles to provide actual Application lifecycle status with
* callbacks on background/foreground changes.
*/
public class ApplicationLifecycle {
/**
* Static instance to handle static callback registration
*/
private static ApplicationLifecycle sInstance;
private HokoApplicationStatus mApplicationStatus;
private List<ApplicationLifecycleCallback> mCallbacks;
/**
* Private initializer, starting on FOREGROUND since it is what actually makes sense.
*
* @param context A context.
*/
private ApplicationLifecycle(Context context) {
mCallbacks = new ArrayList<>();
mApplicationStatus = HokoApplicationStatus.FOREGROUND;
try {
registerActivityLifecycle(context);
} catch (NullPointerException e) {
|
HokoLog.e(e);
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/utils/lifecycle/ApplicationLifecycle.java
|
// Path: hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
// @SuppressLint("Registered")
// public class HokoActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
// @SuppressLint("Registered")
// public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
|
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import com.hokolinks.activity.HokoActivity;
import com.hokolinks.activity.HokoAppLinksActivity;
import com.hokolinks.utils.log.HokoLog;
import java.util.ArrayList;
import java.util.List;
|
}
}
/**
* Background happens when an activity is paused and stopped without any resumes in the middle.
* Foreground might happen on every resume, it is only triggered when the application's state is
* BACKGROUND. Ignoring HokoActivity due to Intent flags.
*
* @param context A context.
*/
private void registerActivityLifecycle(Context context) {
if (context != null) {
Application application = (Application) context.getApplicationContext();
application.registerActivityLifecycleCallbacks(
new Application.ActivityLifecycleCallbacks() {
private ArrayList<HokoActivityStatus> statusHistory =
new ArrayList<>();
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
|
// Path: hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
// @SuppressLint("Registered")
// public class HokoActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
// @SuppressLint("Registered")
// public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
// Path: hoko/src/main/java/com/hokolinks/utils/lifecycle/ApplicationLifecycle.java
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import com.hokolinks.activity.HokoActivity;
import com.hokolinks.activity.HokoAppLinksActivity;
import com.hokolinks.utils.log.HokoLog;
import java.util.ArrayList;
import java.util.List;
}
}
/**
* Background happens when an activity is paused and stopped without any resumes in the middle.
* Foreground might happen on every resume, it is only triggered when the application's state is
* BACKGROUND. Ignoring HokoActivity due to Intent flags.
*
* @param context A context.
*/
private void registerActivityLifecycle(Context context) {
if (context != null) {
Application application = (Application) context.getApplicationContext();
application.registerActivityLifecycleCallbacks(
new Application.ActivityLifecycleCallbacks() {
private ArrayList<HokoActivityStatus> statusHistory =
new ArrayList<>();
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
|
if (activity instanceof HokoActivity ||
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/utils/lifecycle/ApplicationLifecycle.java
|
// Path: hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
// @SuppressLint("Registered")
// public class HokoActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
// @SuppressLint("Registered")
// public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
|
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import com.hokolinks.activity.HokoActivity;
import com.hokolinks.activity.HokoAppLinksActivity;
import com.hokolinks.utils.log.HokoLog;
import java.util.ArrayList;
import java.util.List;
|
}
/**
* Background happens when an activity is paused and stopped without any resumes in the middle.
* Foreground might happen on every resume, it is only triggered when the application's state is
* BACKGROUND. Ignoring HokoActivity due to Intent flags.
*
* @param context A context.
*/
private void registerActivityLifecycle(Context context) {
if (context != null) {
Application application = (Application) context.getApplicationContext();
application.registerActivityLifecycleCallbacks(
new Application.ActivityLifecycleCallbacks() {
private ArrayList<HokoActivityStatus> statusHistory =
new ArrayList<>();
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
if (activity instanceof HokoActivity ||
|
// Path: hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
// @SuppressLint("Registered")
// public class HokoActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/activity/HokoAppLinksActivity.java
// @SuppressLint("Registered")
// public class HokoAppLinksActivity extends Activity implements SmartlinkResolveListener {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// String urlString = getIntent().getData().toString();
// if (urlString.startsWith("http")) {
// Hoko.deeplinking().openSmartlink(urlString, this);
// } else {
// Hoko.deeplinking().openURL(urlString);
// }
// }
//
// @Override
// public void onLinkResolved(String deeplink, JSONObject metadata) {
// finish();
// }
//
// @Override
// public void onError(Exception e) {
// finish();
// Hoko.deeplinking().openURL(null);
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
// Path: hoko/src/main/java/com/hokolinks/utils/lifecycle/ApplicationLifecycle.java
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import com.hokolinks.activity.HokoActivity;
import com.hokolinks.activity.HokoAppLinksActivity;
import com.hokolinks.utils.log.HokoLog;
import java.util.ArrayList;
import java.util.List;
}
/**
* Background happens when an activity is paused and stopped without any resumes in the middle.
* Foreground might happen on every resume, it is only triggered when the application's state is
* BACKGROUND. Ignoring HokoActivity due to Intent flags.
*
* @param context A context.
*/
private void registerActivityLifecycle(Context context) {
if (context != null) {
Application application = (Application) context.getApplicationContext();
application.registerActivityLifecycleCallbacks(
new Application.ActivityLifecycleCallbacks() {
private ArrayList<HokoActivityStatus> statusHistory =
new ArrayList<>();
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
if (activity instanceof HokoActivity ||
|
activity instanceof HokoAppLinksActivity)
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
|
// Path: hoko/src/main/java/com/hokolinks/Hoko.java
// public class Hoko {
//
// public static final String VERSION = "2.3.0";
//
// // Static Instance
// private static Hoko sInstance;
//
// // Private modules
// private Deeplinking mDeeplinking;
//
// // Private variables
// private boolean mDebugMode;
// private String mToken;
//
// // Private initializer
// private Hoko(Context context, String token, boolean debugMode) {
// mDebugMode = debugMode;
// mToken = token;
// Networking.setupNetworking(context);
//
// mDeeplinking = new Deeplinking(token, context);
// }
//
// // Setup
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode according to your generated BuildConfig class, which depends on your
// * Build Variant. Debug mode serves the purpose of uploading the mapped Routes to the Hoko
// * backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN");
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// */
// public static void setup(Context context, String token) {
// setup(context, token, App.isDebug(context));
// }
//
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode for the devices set. Debug mode serves the purpose of uploading
// * the mapped Routes to the Hoko backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN", true);
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// * @param debugMode Toggle debug mode manually.
// */
// public static void setup(Context context, String token, boolean debugMode) {
// if (sInstance == null) {
// sInstance = new Hoko(context, token, debugMode);
// sInstance.checkVersions();
// AnnotationParser.parseActivities(context);
//
// } else {
// HokoLog.e(new SetupCalledMoreThanOnceException());
// }
// }
//
// // Modules
//
// /**
// * The Deeplinking module provides all the necessary APIs to map, handle and generate
// * deeplinks.
// * Different APIs as provided in order to be as versatile as your application requires them to
// * be.
// *
// * @return A reference to the Deeplinking instance.
// */
// public static Deeplinking deeplinking() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return null;
// }
// return sInstance.mDeeplinking;
// }
//
// // Logging
//
// /**
// * Use this function to enable or disable logging from the Hoko SDK.
// * It is disabled by default.
// *
// * @param verbose true to enable logging, false to disable.
// */
// public static void setVerbose(boolean verbose) {
// HokoLog.setVerbose(verbose);
// }
//
// // Debug
//
// /**
// * Returns a boolean on whether the debug mode is activated or not.
// *
// * @return true if debug mode is on, false otherwise.
// */
// public static boolean isDebugMode() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return false;
// }
// return sInstance.mDebugMode;
// }
//
// /**
// * Checks for new SDK version on GITHUB, also checks for which version was previously installed,
// * and in case its different it will reset the routes that were previously posted, to allow new
// * routes to be posted.
// */
// private void checkVersions() {
// if (mDebugMode) {
// VersionChecker.checkForNewVersion(VERSION, mToken);
// }
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/deeplinking/listeners/SmartlinkResolveListener.java
// public interface SmartlinkResolveListener {
//
// void onLinkResolved(String deeplink, JSONObject metadata);
//
// void onError(Exception e);
//
// }
|
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import com.hokolinks.Hoko;
import com.hokolinks.deeplinking.listeners.SmartlinkResolveListener;
import org.json.JSONObject;
|
package com.hokolinks.activity;
/**
* HokoActivity serves the purpose of receiving incoming deeplinking intents and forwarding them to
* the Deeplinking module where it will be parsed and start the associated activity.
*/
@SuppressLint("Registered")
public class HokoActivity extends Activity implements SmartlinkResolveListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String urlString = getIntent().getData().toString();
if (urlString.startsWith("http")) {
|
// Path: hoko/src/main/java/com/hokolinks/Hoko.java
// public class Hoko {
//
// public static final String VERSION = "2.3.0";
//
// // Static Instance
// private static Hoko sInstance;
//
// // Private modules
// private Deeplinking mDeeplinking;
//
// // Private variables
// private boolean mDebugMode;
// private String mToken;
//
// // Private initializer
// private Hoko(Context context, String token, boolean debugMode) {
// mDebugMode = debugMode;
// mToken = token;
// Networking.setupNetworking(context);
//
// mDeeplinking = new Deeplinking(token, context);
// }
//
// // Setup
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode according to your generated BuildConfig class, which depends on your
// * Build Variant. Debug mode serves the purpose of uploading the mapped Routes to the Hoko
// * backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN");
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// */
// public static void setup(Context context, String token) {
// setup(context, token, App.isDebug(context));
// }
//
// /**
// * Setups all the Hoko module instances, logging and asynchronous networking queues.
// * Setting up with a token will make sure you can take full advantage of the Hoko service,
// * as you will be able to track everything through automatic Analytics, which will
// * be shown on your Hoko dashboards.
// * Also sets the debug mode for the devices set. Debug mode serves the purpose of uploading
// * the mapped Routes to the Hoko backend service.
// * <pre>{@code
// * Hoko.setup(this, "YOUR-API-TOKEN", true);
// * }</pre>
// *
// * @param context Your application context.
// * @param token Hoko service API key.
// * @param debugMode Toggle debug mode manually.
// */
// public static void setup(Context context, String token, boolean debugMode) {
// if (sInstance == null) {
// sInstance = new Hoko(context, token, debugMode);
// sInstance.checkVersions();
// AnnotationParser.parseActivities(context);
//
// } else {
// HokoLog.e(new SetupCalledMoreThanOnceException());
// }
// }
//
// // Modules
//
// /**
// * The Deeplinking module provides all the necessary APIs to map, handle and generate
// * deeplinks.
// * Different APIs as provided in order to be as versatile as your application requires them to
// * be.
// *
// * @return A reference to the Deeplinking instance.
// */
// public static Deeplinking deeplinking() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return null;
// }
// return sInstance.mDeeplinking;
// }
//
// // Logging
//
// /**
// * Use this function to enable or disable logging from the Hoko SDK.
// * It is disabled by default.
// *
// * @param verbose true to enable logging, false to disable.
// */
// public static void setVerbose(boolean verbose) {
// HokoLog.setVerbose(verbose);
// }
//
// // Debug
//
// /**
// * Returns a boolean on whether the debug mode is activated or not.
// *
// * @return true if debug mode is on, false otherwise.
// */
// public static boolean isDebugMode() {
// if (sInstance == null) {
// HokoLog.e(new SetupNotCalledYetException());
// return false;
// }
// return sInstance.mDebugMode;
// }
//
// /**
// * Checks for new SDK version on GITHUB, also checks for which version was previously installed,
// * and in case its different it will reset the routes that were previously posted, to allow new
// * routes to be posted.
// */
// private void checkVersions() {
// if (mDebugMode) {
// VersionChecker.checkForNewVersion(VERSION, mToken);
// }
// }
//
// }
//
// Path: hoko/src/main/java/com/hokolinks/deeplinking/listeners/SmartlinkResolveListener.java
// public interface SmartlinkResolveListener {
//
// void onLinkResolved(String deeplink, JSONObject metadata);
//
// void onError(Exception e);
//
// }
// Path: hoko/src/main/java/com/hokolinks/activity/HokoActivity.java
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import com.hokolinks.Hoko;
import com.hokolinks.deeplinking.listeners.SmartlinkResolveListener;
import org.json.JSONObject;
package com.hokolinks.activity;
/**
* HokoActivity serves the purpose of receiving incoming deeplinking intents and forwarding them to
* the Deeplinking module where it will be parsed and start the associated activity.
*/
@SuppressLint("Registered")
public class HokoActivity extends Activity implements SmartlinkResolveListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String urlString = getIntent().getData().toString();
if (urlString.startsWith("http")) {
|
Hoko.deeplinking().openSmartlink(urlString, this);
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/model/IntentRouteImpl.java
|
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
|
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.hokolinks.utils.log.HokoLog;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
|
HashMap<String, Field> queryParameters, Context context) {
super(route);
mActivityClassName = activityClassName;
mRouteParameters = routeParameters;
mQueryParameters = queryParameters;
mContext = context;
}
public String getActivityClassName() {
return mActivityClassName;
}
public HashMap<String, Field> getRouteParameters() {
return mRouteParameters;
}
public HashMap<String, Field> getQueryParameters() {
return mQueryParameters;
}
/**
* Retrieves the actual class out of the activity's class name.
*
* @return A class object or null.
*/
private Class getActivityClass() {
try {
return Class.forName(mActivityClassName);
} catch (ClassNotFoundException e) {
|
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
// Path: hoko/src/main/java/com/hokolinks/model/IntentRouteImpl.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.hokolinks.utils.log.HokoLog;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
HashMap<String, Field> queryParameters, Context context) {
super(route);
mActivityClassName = activityClassName;
mRouteParameters = routeParameters;
mQueryParameters = queryParameters;
mContext = context;
}
public String getActivityClassName() {
return mActivityClassName;
}
public HashMap<String, Field> getRouteParameters() {
return mRouteParameters;
}
public HashMap<String, Field> getQueryParameters() {
return mQueryParameters;
}
/**
* Retrieves the actual class out of the activity's class name.
*
* @return A class object or null.
*/
private Class getActivityClass() {
try {
return Class.forName(mActivityClassName);
} catch (ClassNotFoundException e) {
|
HokoLog.e(e);
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/model/App.java
|
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
|
import android.content.Context;
import android.content.pm.PackageInfo;
import com.hokolinks.utils.log.HokoLog;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Field;
|
package com.hokolinks.model;
/**
* App is a helper class to get all the necessary information of the Application environment.
*/
public class App {
private static final String ENVIRONMENT_DEBUG = "debug";
private static final String ENVIRONMENT_RELEASE = "release";
/**
* Returns the name of the application Hoko is being run on.
*
* @param context A context object.
* @return The name of the application.
*/
public static String getName(Context context) {
try {
int stringId = context.getApplicationInfo().labelRes;
return context.getString(stringId);
} catch (NullPointerException e) {
|
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
// Path: hoko/src/main/java/com/hokolinks/model/App.java
import android.content.Context;
import android.content.pm.PackageInfo;
import com.hokolinks.utils.log.HokoLog;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Field;
package com.hokolinks.model;
/**
* App is a helper class to get all the necessary information of the Application environment.
*/
public class App {
private static final String ENVIRONMENT_DEBUG = "debug";
private static final String ENVIRONMENT_RELEASE = "release";
/**
* Returns the name of the application Hoko is being run on.
*
* @param context A context object.
* @return The name of the application.
*/
public static String getName(Context context) {
try {
int stringId = context.getApplicationInfo().labelRes;
return context.getString(stringId);
} catch (NullPointerException e) {
|
HokoLog.e(e);
|
hoko/hoko-android
|
hoko/src/main/java/com/hokolinks/utils/Utils.java
|
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import com.hokolinks.utils.log.HokoLog;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Calendar;
import java.util.Locale;
import java.util.UUID;
|
package com.hokolinks.utils;
/**
* Utils serves many purposes, but mostly loading and saving objects/strings to file or
* to the SharedPreferences. It also provides utility methods to generate random UUIDs and
* sanitizing routes.
*/
public class Utils {
// Hoko folder name
private static final String FOLDER_NAME = "hoko";
// Hoko SharedPreferences key
private static final String SHARED_PREFERENCES_STRING_KEY = "com.hoko.string";
/**
* Checks where the application has a given permission granted on the AndroidManifest.xml file.
*
* @param permission The permission to be checked.
* @param context A context object.
* @return true if has permission, false otherwise.
*/
public static boolean hasPermission(String permission, Context context) {
try {
PackageManager packageManager = context.getPackageManager();
if (packageManager.checkPermission(permission, context.getPackageName())
== PackageManager.PERMISSION_GRANTED) {
return true;
} else {
|
// Path: hoko/src/main/java/com/hokolinks/utils/log/HokoLog.java
// public class HokoLog {
// /**
// * The Log TAG
// */
// public static final String TAG = "HOKO";
//
// /**
// * Verbose is false by default
// */
// private static boolean sVerbose = false;
//
// /**
// * Prints a debug message.
// *
// * @param message The message.
// */
// public static void d(String message) {
// if (sVerbose) {
// android.util.Log.d(TAG, message);
// }
// }
//
// /**
// * Prints a debug exception.
// *
// * @param exception The exception.
// */
// public static void d(Exception exception) {
// if (sVerbose) {
// android.util.Log.d(TAG, exception.getMessage(), exception);
// }
// }
//
// /**
// * Prints a message as an error.
// *
// * @param message The message.
// */
// public static void e(String message) {
// android.util.Log.e(TAG, message);
// }
//
// /**
// * Prints an exception as an error.
// *
// * @param exception The exception.
// */
// public static void e(Exception exception) {
// android.util.Log.e(TAG, exception.getMessage(), exception);
// }
//
// /**
// * Prints an error.
// *
// * @param error The exception.
// */
// public static void e(Error error) {
// android.util.Log.e(TAG, error.getMessage(), error);
// }
//
// public static boolean isVerbose() {
// return sVerbose;
// }
//
// public static void setVerbose(boolean verbose) {
// HokoLog.sVerbose = verbose;
// }
//
// }
// Path: hoko/src/main/java/com/hokolinks/utils/Utils.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import com.hokolinks.utils.log.HokoLog;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Calendar;
import java.util.Locale;
import java.util.UUID;
package com.hokolinks.utils;
/**
* Utils serves many purposes, but mostly loading and saving objects/strings to file or
* to the SharedPreferences. It also provides utility methods to generate random UUIDs and
* sanitizing routes.
*/
public class Utils {
// Hoko folder name
private static final String FOLDER_NAME = "hoko";
// Hoko SharedPreferences key
private static final String SHARED_PREFERENCES_STRING_KEY = "com.hoko.string";
/**
* Checks where the application has a given permission granted on the AndroidManifest.xml file.
*
* @param permission The permission to be checked.
* @param context A context object.
* @return true if has permission, false otherwise.
*/
public static boolean hasPermission(String permission, Context context) {
try {
PackageManager packageManager = context.getPackageManager();
if (packageManager.checkPermission(permission, context.getPackageName())
== PackageManager.PERMISSION_GRANTED) {
return true;
} else {
|
HokoLog.e("Requesting permission " + permission
|
vocobox/vocobox
|
dev/java/vocobox-apps/src/main/java/org/vocobox/apps/benchmark/charts/NoteMozaic.java
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/note/Voyel.java
// public enum Voyel {
// A, E, I, O, OU, U;
//
// public static Voyel parse(String voyel){
// for(Voyel v: Voyel.values()){
// if(v.toString().equals(voyel.toUpperCase())){
// return v;
// }
// }
// System.out.println("did not parse " + voyel);
// return null;
// //throw new IllegalArgumentException("not a voyel : " + voyel + ". Try among " + Voyel.values());
// }
// }
|
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jzy3d.chart.Chart;
import org.vocobox.io.datasets.HumanVoiceDataset;
import org.vocobox.model.note.MAPSNote;
import org.vocobox.model.note.Note;
import org.vocobox.model.note.NoteDescriptor;
import org.vocobox.model.note.NoteDescriptors;
import org.vocobox.model.note.Voyel;
|
package org.vocobox.apps.benchmark.charts;
public class NoteMozaic {
public static Chart[][] oneNote(String name, float expected, float semitoneDistance) throws Exception {
Note note = HumanVoiceDataset.NOTES.getNote(name);
Chart[][] charts = new Chart[2][1];
charts[0][0] = chartFrequency(note);
charts[0][1] = chartEval(note, semitoneDistance);
return charts;
}
public static Chart[][] evalChartsPitch(Note[][] notes, int startAt, float semitoneError) throws Exception {
int octaves = notes.length;
int semitones = notes[0].length;
Chart[][] charts = new Chart[(octaves - startAt) * 2][semitones];
for (int octave = startAt; octave < octaves; octave++) {
for (int tone = 0; tone < notes[octave].length; tone++) {
Note note = notes[octave][tone];
if (note != null) {
charts[octave - startAt][tone] = chartFrequency(note);
charts[octave - startAt + octaves][tone] = chartEval(note, semitoneError);
}
}
}
return charts;
}
/* */
public static Chart[][] evalChartsVoyels(List<Note> voyels) throws Exception {
return evalChartsVoyels(getVoyelMatrix(voyels));
}
public static Chart[][] evalChartsVoyels(Note[][] voyels) throws Exception {
Chart[][] charts = new Chart[2][voyels.length];
for (int tone = 0; tone < voyels.length; tone++) {
Note note = voyels[tone][0];
if (note != null) {
charts[0][tone] = chartFrequency(note);
charts[1][tone] = chartEval(note, 0.5f);
}
}
return charts;
}
public static Chart[][] evalChartsVoyelInstances(Note[][] voyels) throws Exception {
Chart[][] charts = new Chart[voyels.length][voyels[0].length*2];
for (int i = 0; i < voyels.length; i++) {
for (int j = 0; j < voyels[i].length; j++) {
Note note = voyels[i][j];
if(note!=null){
charts[i][j] = chartFrequency(note);
charts[i][j+voyels[0].length] = chartEval(note, 0.5f);
}
}
}
return charts;
}
public static Note[][] getVoyelMatrix(List<Note> notes) {
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/note/Voyel.java
// public enum Voyel {
// A, E, I, O, OU, U;
//
// public static Voyel parse(String voyel){
// for(Voyel v: Voyel.values()){
// if(v.toString().equals(voyel.toUpperCase())){
// return v;
// }
// }
// System.out.println("did not parse " + voyel);
// return null;
// //throw new IllegalArgumentException("not a voyel : " + voyel + ". Try among " + Voyel.values());
// }
// }
// Path: dev/java/vocobox-apps/src/main/java/org/vocobox/apps/benchmark/charts/NoteMozaic.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jzy3d.chart.Chart;
import org.vocobox.io.datasets.HumanVoiceDataset;
import org.vocobox.model.note.MAPSNote;
import org.vocobox.model.note.Note;
import org.vocobox.model.note.NoteDescriptor;
import org.vocobox.model.note.NoteDescriptors;
import org.vocobox.model.note.Voyel;
package org.vocobox.apps.benchmark.charts;
public class NoteMozaic {
public static Chart[][] oneNote(String name, float expected, float semitoneDistance) throws Exception {
Note note = HumanVoiceDataset.NOTES.getNote(name);
Chart[][] charts = new Chart[2][1];
charts[0][0] = chartFrequency(note);
charts[0][1] = chartEval(note, semitoneDistance);
return charts;
}
public static Chart[][] evalChartsPitch(Note[][] notes, int startAt, float semitoneError) throws Exception {
int octaves = notes.length;
int semitones = notes[0].length;
Chart[][] charts = new Chart[(octaves - startAt) * 2][semitones];
for (int octave = startAt; octave < octaves; octave++) {
for (int tone = 0; tone < notes[octave].length; tone++) {
Note note = notes[octave][tone];
if (note != null) {
charts[octave - startAt][tone] = chartFrequency(note);
charts[octave - startAt + octaves][tone] = chartEval(note, semitoneError);
}
}
}
return charts;
}
/* */
public static Chart[][] evalChartsVoyels(List<Note> voyels) throws Exception {
return evalChartsVoyels(getVoyelMatrix(voyels));
}
public static Chart[][] evalChartsVoyels(Note[][] voyels) throws Exception {
Chart[][] charts = new Chart[2][voyels.length];
for (int tone = 0; tone < voyels.length; tone++) {
Note note = voyels[tone][0];
if (note != null) {
charts[0][tone] = chartFrequency(note);
charts[1][tone] = chartEval(note, 0.5f);
}
}
return charts;
}
public static Chart[][] evalChartsVoyelInstances(Note[][] voyels) throws Exception {
Chart[][] charts = new Chart[voyels.length][voyels[0].length*2];
for (int i = 0; i < voyels.length; i++) {
for (int j = 0; j < voyels[i].length; j++) {
Note note = voyels[i][j];
if(note!=null){
charts[i][j] = chartFrequency(note);
charts[i][j+voyels[0].length] = chartEval(note, 0.5f);
}
}
}
return charts;
}
public static Note[][] getVoyelMatrix(List<Note> notes) {
|
Note[][] matrix = new Note[Voyel.values().length][1];
|
vocobox/vocobox
|
dev/java/vocobox-api/src/main/java/org/vocobox/events/policies/DefaultSoundEventPolicy.java
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/events/On.java
// public interface On {
// public void finish();
// }
//
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/synth/VocoSynth.java
// public interface VocoSynth {
// // enable
// public void wire();
// public void on() throws Exception;
// public void off();
//
// // play
// public void sendAmplitude(float amplitude);
// public void sendFrequency(float frequency);
// public void sendConfidence(float confidence);
// public void sendOnset(float salience);
// public void sendOffset();
//
// // monitor
// public SynthMonitor getMonitor();
// public void setMonitor(SynthMonitor monitor);
// public SynthMonitorCharts getDefaultMonitor(MonitorSettings settings);
//
// // UI controller
// public JPanel newControlPanel();
// }
|
import java.util.List;
import org.vocobox.events.On;
import org.vocobox.events.SoundEvent;
import org.vocobox.model.synth.VocoSynth;
|
package org.vocobox.events.policies;
public class DefaultSoundEventPolicy extends AbstractSoundEventPolicy {
public DefaultSoundEventPolicy() {
super();
}
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/events/On.java
// public interface On {
// public void finish();
// }
//
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/synth/VocoSynth.java
// public interface VocoSynth {
// // enable
// public void wire();
// public void on() throws Exception;
// public void off();
//
// // play
// public void sendAmplitude(float amplitude);
// public void sendFrequency(float frequency);
// public void sendConfidence(float confidence);
// public void sendOnset(float salience);
// public void sendOffset();
//
// // monitor
// public SynthMonitor getMonitor();
// public void setMonitor(SynthMonitor monitor);
// public SynthMonitorCharts getDefaultMonitor(MonitorSettings settings);
//
// // UI controller
// public JPanel newControlPanel();
// }
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/events/policies/DefaultSoundEventPolicy.java
import java.util.List;
import org.vocobox.events.On;
import org.vocobox.events.SoundEvent;
import org.vocobox.model.synth.VocoSynth;
package org.vocobox.events.policies;
public class DefaultSoundEventPolicy extends AbstractSoundEventPolicy {
public DefaultSoundEventPolicy() {
super();
}
|
public DefaultSoundEventPolicy(VocoSynth synth) {
|
vocobox/vocobox
|
dev/java/vocobox-api/src/main/java/org/vocobox/events/policies/DefaultSoundEventPolicy.java
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/events/On.java
// public interface On {
// public void finish();
// }
//
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/synth/VocoSynth.java
// public interface VocoSynth {
// // enable
// public void wire();
// public void on() throws Exception;
// public void off();
//
// // play
// public void sendAmplitude(float amplitude);
// public void sendFrequency(float frequency);
// public void sendConfidence(float confidence);
// public void sendOnset(float salience);
// public void sendOffset();
//
// // monitor
// public SynthMonitor getMonitor();
// public void setMonitor(SynthMonitor monitor);
// public SynthMonitorCharts getDefaultMonitor(MonitorSettings settings);
//
// // UI controller
// public JPanel newControlPanel();
// }
|
import java.util.List;
import org.vocobox.events.On;
import org.vocobox.events.SoundEvent;
import org.vocobox.model.synth.VocoSynth;
|
package org.vocobox.events.policies;
public class DefaultSoundEventPolicy extends AbstractSoundEventPolicy {
public DefaultSoundEventPolicy() {
super();
}
public DefaultSoundEventPolicy(VocoSynth synth) {
super(synth);
}
@Override
public void onPitch(SoundEvent e) {
synth.sendFrequency(e.value);
}
@Override
public void onAmplitude(SoundEvent e) {
float a = e.value;//getNormalizeAmplitude(e);
// System.out.println(a);
synth.sendAmplitude(a);
}
public float getNormalizeAmplitude(SoundEvent e) {
//System.out.println("normalized amplitude : " + e.value + " max : " + amplitudeEventConsumer.getStatistics().max);
return e.value / amplitudeEventConsumer.getStatistics().max;
}
/* */
@Override
public void play() {
amplitudeEventConsumer.runnerStart();
pitchEventConsumer.runnerStart();
}
@Override
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/events/On.java
// public interface On {
// public void finish();
// }
//
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/synth/VocoSynth.java
// public interface VocoSynth {
// // enable
// public void wire();
// public void on() throws Exception;
// public void off();
//
// // play
// public void sendAmplitude(float amplitude);
// public void sendFrequency(float frequency);
// public void sendConfidence(float confidence);
// public void sendOnset(float salience);
// public void sendOffset();
//
// // monitor
// public SynthMonitor getMonitor();
// public void setMonitor(SynthMonitor monitor);
// public SynthMonitorCharts getDefaultMonitor(MonitorSettings settings);
//
// // UI controller
// public JPanel newControlPanel();
// }
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/events/policies/DefaultSoundEventPolicy.java
import java.util.List;
import org.vocobox.events.On;
import org.vocobox.events.SoundEvent;
import org.vocobox.model.synth.VocoSynth;
package org.vocobox.events.policies;
public class DefaultSoundEventPolicy extends AbstractSoundEventPolicy {
public DefaultSoundEventPolicy() {
super();
}
public DefaultSoundEventPolicy(VocoSynth synth) {
super(synth);
}
@Override
public void onPitch(SoundEvent e) {
synth.sendFrequency(e.value);
}
@Override
public void onAmplitude(SoundEvent e) {
float a = e.value;//getNormalizeAmplitude(e);
// System.out.println(a);
synth.sendAmplitude(a);
}
public float getNormalizeAmplitude(SoundEvent e) {
//System.out.println("normalized amplitude : " + e.value + " max : " + amplitudeEventConsumer.getStatistics().max);
return e.value / amplitudeEventConsumer.getStatistics().max;
}
/* */
@Override
public void play() {
amplitudeEventConsumer.runnerStart();
pitchEventConsumer.runnerStart();
}
@Override
|
public void play(On finish) {
|
vocobox/vocobox
|
dev/java/vocobox-api/src/main/java/org/vocobox/ui/charts/synth/SynthMonitorCharts.java
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/voice/pitch/evaluate/PitchPrecisionDistanceInSemitone.java
// public class PitchPrecisionDistanceInSemitone implements PitchPrecisionDistance {
// public static final float NOTE_A4_FREQ = 440f;
// public static final int SEMITONES = 12;
//
// /**
// *
// * Return the semitone distance between the estimated and expected
// * frequency.
// *
// * Example : considering those three notes
// * <ul>
// * <li>A4 : 440.00 Hz
// * <li>Ab4 : 415.30 Hz
// * <li>A#4 : 466.16 Hz
// * </ul>
// *
// * Any frequency in the following range will be considered to be A4:
// * <ul>
// * <li>mean(freq(Ab4), freq(A4)) : A4 lower bound (also Ab4 upper bound)
// * <li>mean(freq(A4), freq(A#4)) : A4 upper bound (also A#4 lower bound)
// * </ul>
// *
// * @param expectedFrequency
// * @param estimatedFrequency
// * @return
// */
// @Override
// public double distance(float expectedFrequency, float estimatedFrequency) {
// return noteSemitoneValue(expectedFrequency) - noteSemitoneValue(estimatedFrequency);
// }
//
// public double noteSemitoneValue(float frequency) {
// return SEMITONES * log2(frequency / NOTE_A4_FREQ);
// }
//
// /** http://www.bibmath.net/dico/index.php3?action=affiche&quoi=./l/logarithme.html
// * http://gilles.costantini.pagesperso-orange.fr/Lycee_fichiers/CoursT_fichiers/ExpLn03.pdf
// * */
// /*public float semitoneValueToFrequency(){
//
// }*/
//
// /**
// * y=log2(x) <-> x=2^y
// */
// public double log2(float x) {
// return Math.log(x) / Math.log(2);
// }
//
// /**
// * y=log2(x) <-> x=2^y
// */
// public double log2Inverse(float y) {
// return Math.pow(2, y);
// }
//
// /**
// * Expect "clean" frequency as input, e.g. 440.0f for A4 Output : a lower
// * limit to define a range around input frequency
// */
// public int noteLowerBound(float frequency) {
// return 0;
// }
//
// public int noteUpperBound(float frequency) {
// return 0;
// }
// }
//
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/ui/Palette.java
// public class Palette {
// public static void apply(Chart chart){
// IAxeLayout axe = chart.getAxeLayout();
// axe.setMainColor(Color.WHITE);
// chart.getView().setBackgroundColor(Color.BLACK);
// }
//
// public static void apply(SynthMonitorCharts charts){
// charts.settings.confiColor = Color.BLUE.clone();
// charts.settings.pitchColor = Color.MAGENTA.clone();
// charts.settings.ampliColor = Color.CYAN.clone();
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart2d.Chart2d;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.BoundingBox3d;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot2d.primitives.Serie2d;
import org.jzy3d.plot3d.primitives.axes.AxeBox;
import org.jzy3d.plot3d.primitives.axes.AxeCrossAnnotation;
import org.jzy3d.plot3d.primitives.axes.AxeXLineAnnotation;
import org.jzy3d.plot3d.primitives.axes.AxeXRectangleAnnotation;
import org.jzy3d.plot3d.primitives.axes.IAxe;
import org.jzy3d.plot3d.primitives.axes.layout.IAxeLayout;
import org.jzy3d.plot3d.primitives.axes.layout.providers.PitchTickProvider;
import org.jzy3d.plot3d.primitives.axes.layout.providers.RegularTickProvider;
import org.jzy3d.plot3d.primitives.axes.layout.renderers.IntegerTickRenderer;
import org.jzy3d.plot3d.primitives.axes.layout.renderers.PitchTickRenderer;
import org.jzy3d.plot3d.rendering.view.View;
import org.jzy3d.plot3d.rendering.view.modes.ViewBoundMode;
import org.jzy3d.plot3d.transform.space.SpaceTransformLog2;
import org.jzy3d.plot3d.transform.space.SpaceTransformer;
import org.vocobox.model.synth.MonitorSettings;
import org.vocobox.model.synth.SynthMonitor;
import org.vocobox.model.synth.SynthMonitorDefault;
import org.vocobox.model.voice.pitch.evaluate.PitchPrecisionDistanceInSemitone;
import org.vocobox.ui.Palette;
|
public float currentConfidenceReadOnly = 1;
public float currentAmplitudeReadOnly = 1;
protected float expectedFrequency;
public PitchPrecisionDistanceInSemitone getPitchPrecisionEvaluator() {
return new PitchPrecisionDistanceInSemitone();
}
/*
* ###################################################################
*/
public SynthMonitorCharts() {
this(MonitorSettings.DEFAULT, true, true);
}
public SynthMonitorCharts(MonitorSettings settings) {
this(settings, true, true);
}
public SynthMonitorCharts(MonitorSettings settings, boolean init, boolean startThreads) {
super();
this.settings = settings;
if (init) {
init(settings, settings.applyPalette);
}
}
public void init(MonitorSettings settings, boolean applyPalette) {
if (applyPalette)
|
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/model/voice/pitch/evaluate/PitchPrecisionDistanceInSemitone.java
// public class PitchPrecisionDistanceInSemitone implements PitchPrecisionDistance {
// public static final float NOTE_A4_FREQ = 440f;
// public static final int SEMITONES = 12;
//
// /**
// *
// * Return the semitone distance between the estimated and expected
// * frequency.
// *
// * Example : considering those three notes
// * <ul>
// * <li>A4 : 440.00 Hz
// * <li>Ab4 : 415.30 Hz
// * <li>A#4 : 466.16 Hz
// * </ul>
// *
// * Any frequency in the following range will be considered to be A4:
// * <ul>
// * <li>mean(freq(Ab4), freq(A4)) : A4 lower bound (also Ab4 upper bound)
// * <li>mean(freq(A4), freq(A#4)) : A4 upper bound (also A#4 lower bound)
// * </ul>
// *
// * @param expectedFrequency
// * @param estimatedFrequency
// * @return
// */
// @Override
// public double distance(float expectedFrequency, float estimatedFrequency) {
// return noteSemitoneValue(expectedFrequency) - noteSemitoneValue(estimatedFrequency);
// }
//
// public double noteSemitoneValue(float frequency) {
// return SEMITONES * log2(frequency / NOTE_A4_FREQ);
// }
//
// /** http://www.bibmath.net/dico/index.php3?action=affiche&quoi=./l/logarithme.html
// * http://gilles.costantini.pagesperso-orange.fr/Lycee_fichiers/CoursT_fichiers/ExpLn03.pdf
// * */
// /*public float semitoneValueToFrequency(){
//
// }*/
//
// /**
// * y=log2(x) <-> x=2^y
// */
// public double log2(float x) {
// return Math.log(x) / Math.log(2);
// }
//
// /**
// * y=log2(x) <-> x=2^y
// */
// public double log2Inverse(float y) {
// return Math.pow(2, y);
// }
//
// /**
// * Expect "clean" frequency as input, e.g. 440.0f for A4 Output : a lower
// * limit to define a range around input frequency
// */
// public int noteLowerBound(float frequency) {
// return 0;
// }
//
// public int noteUpperBound(float frequency) {
// return 0;
// }
// }
//
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/ui/Palette.java
// public class Palette {
// public static void apply(Chart chart){
// IAxeLayout axe = chart.getAxeLayout();
// axe.setMainColor(Color.WHITE);
// chart.getView().setBackgroundColor(Color.BLACK);
// }
//
// public static void apply(SynthMonitorCharts charts){
// charts.settings.confiColor = Color.BLUE.clone();
// charts.settings.pitchColor = Color.MAGENTA.clone();
// charts.settings.ampliColor = Color.CYAN.clone();
// }
// }
// Path: dev/java/vocobox-api/src/main/java/org/vocobox/ui/charts/synth/SynthMonitorCharts.java
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart2d.Chart2d;
import org.jzy3d.colors.Color;
import org.jzy3d.maths.BoundingBox3d;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot2d.primitives.Serie2d;
import org.jzy3d.plot3d.primitives.axes.AxeBox;
import org.jzy3d.plot3d.primitives.axes.AxeCrossAnnotation;
import org.jzy3d.plot3d.primitives.axes.AxeXLineAnnotation;
import org.jzy3d.plot3d.primitives.axes.AxeXRectangleAnnotation;
import org.jzy3d.plot3d.primitives.axes.IAxe;
import org.jzy3d.plot3d.primitives.axes.layout.IAxeLayout;
import org.jzy3d.plot3d.primitives.axes.layout.providers.PitchTickProvider;
import org.jzy3d.plot3d.primitives.axes.layout.providers.RegularTickProvider;
import org.jzy3d.plot3d.primitives.axes.layout.renderers.IntegerTickRenderer;
import org.jzy3d.plot3d.primitives.axes.layout.renderers.PitchTickRenderer;
import org.jzy3d.plot3d.rendering.view.View;
import org.jzy3d.plot3d.rendering.view.modes.ViewBoundMode;
import org.jzy3d.plot3d.transform.space.SpaceTransformLog2;
import org.jzy3d.plot3d.transform.space.SpaceTransformer;
import org.vocobox.model.synth.MonitorSettings;
import org.vocobox.model.synth.SynthMonitor;
import org.vocobox.model.synth.SynthMonitorDefault;
import org.vocobox.model.voice.pitch.evaluate.PitchPrecisionDistanceInSemitone;
import org.vocobox.ui.Palette;
public float currentConfidenceReadOnly = 1;
public float currentAmplitudeReadOnly = 1;
protected float expectedFrequency;
public PitchPrecisionDistanceInSemitone getPitchPrecisionEvaluator() {
return new PitchPrecisionDistanceInSemitone();
}
/*
* ###################################################################
*/
public SynthMonitorCharts() {
this(MonitorSettings.DEFAULT, true, true);
}
public SynthMonitorCharts(MonitorSettings settings) {
this(settings, true, true);
}
public SynthMonitorCharts(MonitorSettings settings, boolean init, boolean startThreads) {
super();
this.settings = settings;
if (init) {
init(settings, settings.applyPalette);
}
}
public void init(MonitorSettings settings, boolean applyPalette) {
if (applyPalette)
|
Palette.apply(this); // fix default colors
|
flutterwireless/ArduinoCodebase
|
app/src/processing/app/debug/TargetPackage.java
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// Path: app/src/processing/app/I18n.java
// public class I18n {
// // start using current locale but still allow using the dropdown list later
// private static ResourceBundle i18n;
//
// // prompt text stuff
//
// static String PROMPT_YES;
// static String PROMPT_NO;
// static String PROMPT_CANCEL;
// static String PROMPT_OK;
// static String PROMPT_BROWSE;
//
// static protected void init(String language) throws MissingResourceException {
// String[] languageParts = language.split("_");
// Locale locale = Locale.getDefault();
// // both language and country
// if (languageParts.length == 2) {
// locale = new Locale(languageParts[0], languageParts[1]);
// // just language
// } else if (languageParts.length == 1 && !"".equals(languageParts[0])) {
// locale = new Locale(languageParts[0]);
// }
// // there might be a null pointer exception ... most likely will never happen but the jvm gets mad
// Locale.setDefault(locale);
// i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
// PROMPT_YES = _("Yes");
// PROMPT_NO = _("No");
// PROMPT_CANCEL = _("Cancel");
// PROMPT_OK = _("OK");
// PROMPT_BROWSE = _("Browse");
// }
//
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// public static String format(String fmt, Object... args) {
// // Single quote is used to escape curly bracket arguments.
//
// // - Prevents strings fixed at translation time to be fixed again
// fmt = fmt.replace("''", "'");
// // - Replace ' with the escaped version ''
// fmt = fmt.replace("'", "''");
//
// return MessageFormat.format(fmt, args);
// }
//
// /**
// * Does nothing.
// * <p/>
// * This method is an hack to extract words with gettext tool.
// */
// protected static void unusedStrings() {
// // These phrases are defined in the "platform.txt".
// _("Arduino AVR Boards");
// _("Arduino ARM (32-bits) Boards");
//
// // This word is defined in the "boards.txt".
// _("Processor");
// }
// }
|
import processing.app.I18n;
import processing.app.helpers.filefilters.OnlyDirs;
import static processing.app.I18n._;
import java.io.File;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
|
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
TargetPackage - Represents a hardware package
Part of the Arduino project - http://www.arduino.cc/
Copyright (c) 2011 Cristian Maglie
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id$
*/
package processing.app.debug;
public class TargetPackage {
private String id;
Map<String, TargetPlatform> platforms = new LinkedHashMap<String, TargetPlatform>();
public TargetPackage(String _id, File _folder) throws TargetPlatformException {
id = _id;
File[] folders = _folder.listFiles(new OnlyDirs());
if (folders == null)
return;
for (File subFolder : folders) {
if (!subFolder.exists() || !subFolder.canRead())
continue;
String arch = subFolder.getName();
try {
TargetPlatform platform = new TargetPlatform(arch, subFolder, this);
platforms.put(arch, platform);
} catch (TargetPlatformException e) {
System.out.println(e.getMessage());
}
}
if (platforms.size() == 0) {
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// Path: app/src/processing/app/I18n.java
// public class I18n {
// // start using current locale but still allow using the dropdown list later
// private static ResourceBundle i18n;
//
// // prompt text stuff
//
// static String PROMPT_YES;
// static String PROMPT_NO;
// static String PROMPT_CANCEL;
// static String PROMPT_OK;
// static String PROMPT_BROWSE;
//
// static protected void init(String language) throws MissingResourceException {
// String[] languageParts = language.split("_");
// Locale locale = Locale.getDefault();
// // both language and country
// if (languageParts.length == 2) {
// locale = new Locale(languageParts[0], languageParts[1]);
// // just language
// } else if (languageParts.length == 1 && !"".equals(languageParts[0])) {
// locale = new Locale(languageParts[0]);
// }
// // there might be a null pointer exception ... most likely will never happen but the jvm gets mad
// Locale.setDefault(locale);
// i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
// PROMPT_YES = _("Yes");
// PROMPT_NO = _("No");
// PROMPT_CANCEL = _("Cancel");
// PROMPT_OK = _("OK");
// PROMPT_BROWSE = _("Browse");
// }
//
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// public static String format(String fmt, Object... args) {
// // Single quote is used to escape curly bracket arguments.
//
// // - Prevents strings fixed at translation time to be fixed again
// fmt = fmt.replace("''", "'");
// // - Replace ' with the escaped version ''
// fmt = fmt.replace("'", "''");
//
// return MessageFormat.format(fmt, args);
// }
//
// /**
// * Does nothing.
// * <p/>
// * This method is an hack to extract words with gettext tool.
// */
// protected static void unusedStrings() {
// // These phrases are defined in the "platform.txt".
// _("Arduino AVR Boards");
// _("Arduino ARM (32-bits) Boards");
//
// // This word is defined in the "boards.txt".
// _("Processor");
// }
// }
// Path: app/src/processing/app/debug/TargetPackage.java
import processing.app.I18n;
import processing.app.helpers.filefilters.OnlyDirs;
import static processing.app.I18n._;
import java.io.File;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
TargetPackage - Represents a hardware package
Part of the Arduino project - http://www.arduino.cc/
Copyright (c) 2011 Cristian Maglie
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id$
*/
package processing.app.debug;
public class TargetPackage {
private String id;
Map<String, TargetPlatform> platforms = new LinkedHashMap<String, TargetPlatform>();
public TargetPackage(String _id, File _folder) throws TargetPlatformException {
id = _id;
File[] folders = _folder.listFiles(new OnlyDirs());
if (folders == null)
return;
for (File subFolder : folders) {
if (!subFolder.exists() || !subFolder.canRead())
continue;
String arch = subFolder.getName();
try {
TargetPlatform platform = new TargetPlatform(arch, subFolder, this);
platforms.put(arch, platform);
} catch (TargetPlatformException e) {
System.out.println(e.getMessage());
}
}
if (platforms.size() == 0) {
|
throw new TargetPlatformException(I18n
|
flutterwireless/ArduinoCodebase
|
app/src/processing/app/debug/TargetPackage.java
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// Path: app/src/processing/app/I18n.java
// public class I18n {
// // start using current locale but still allow using the dropdown list later
// private static ResourceBundle i18n;
//
// // prompt text stuff
//
// static String PROMPT_YES;
// static String PROMPT_NO;
// static String PROMPT_CANCEL;
// static String PROMPT_OK;
// static String PROMPT_BROWSE;
//
// static protected void init(String language) throws MissingResourceException {
// String[] languageParts = language.split("_");
// Locale locale = Locale.getDefault();
// // both language and country
// if (languageParts.length == 2) {
// locale = new Locale(languageParts[0], languageParts[1]);
// // just language
// } else if (languageParts.length == 1 && !"".equals(languageParts[0])) {
// locale = new Locale(languageParts[0]);
// }
// // there might be a null pointer exception ... most likely will never happen but the jvm gets mad
// Locale.setDefault(locale);
// i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
// PROMPT_YES = _("Yes");
// PROMPT_NO = _("No");
// PROMPT_CANCEL = _("Cancel");
// PROMPT_OK = _("OK");
// PROMPT_BROWSE = _("Browse");
// }
//
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// public static String format(String fmt, Object... args) {
// // Single quote is used to escape curly bracket arguments.
//
// // - Prevents strings fixed at translation time to be fixed again
// fmt = fmt.replace("''", "'");
// // - Replace ' with the escaped version ''
// fmt = fmt.replace("'", "''");
//
// return MessageFormat.format(fmt, args);
// }
//
// /**
// * Does nothing.
// * <p/>
// * This method is an hack to extract words with gettext tool.
// */
// protected static void unusedStrings() {
// // These phrases are defined in the "platform.txt".
// _("Arduino AVR Boards");
// _("Arduino ARM (32-bits) Boards");
//
// // This word is defined in the "boards.txt".
// _("Processor");
// }
// }
|
import processing.app.I18n;
import processing.app.helpers.filefilters.OnlyDirs;
import static processing.app.I18n._;
import java.io.File;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
|
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
TargetPackage - Represents a hardware package
Part of the Arduino project - http://www.arduino.cc/
Copyright (c) 2011 Cristian Maglie
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id$
*/
package processing.app.debug;
public class TargetPackage {
private String id;
Map<String, TargetPlatform> platforms = new LinkedHashMap<String, TargetPlatform>();
public TargetPackage(String _id, File _folder) throws TargetPlatformException {
id = _id;
File[] folders = _folder.listFiles(new OnlyDirs());
if (folders == null)
return;
for (File subFolder : folders) {
if (!subFolder.exists() || !subFolder.canRead())
continue;
String arch = subFolder.getName();
try {
TargetPlatform platform = new TargetPlatform(arch, subFolder, this);
platforms.put(arch, platform);
} catch (TargetPlatformException e) {
System.out.println(e.getMessage());
}
}
if (platforms.size() == 0) {
throw new TargetPlatformException(I18n
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// Path: app/src/processing/app/I18n.java
// public class I18n {
// // start using current locale but still allow using the dropdown list later
// private static ResourceBundle i18n;
//
// // prompt text stuff
//
// static String PROMPT_YES;
// static String PROMPT_NO;
// static String PROMPT_CANCEL;
// static String PROMPT_OK;
// static String PROMPT_BROWSE;
//
// static protected void init(String language) throws MissingResourceException {
// String[] languageParts = language.split("_");
// Locale locale = Locale.getDefault();
// // both language and country
// if (languageParts.length == 2) {
// locale = new Locale(languageParts[0], languageParts[1]);
// // just language
// } else if (languageParts.length == 1 && !"".equals(languageParts[0])) {
// locale = new Locale(languageParts[0]);
// }
// // there might be a null pointer exception ... most likely will never happen but the jvm gets mad
// Locale.setDefault(locale);
// i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
// PROMPT_YES = _("Yes");
// PROMPT_NO = _("No");
// PROMPT_CANCEL = _("Cancel");
// PROMPT_OK = _("OK");
// PROMPT_BROWSE = _("Browse");
// }
//
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
//
// public static String format(String fmt, Object... args) {
// // Single quote is used to escape curly bracket arguments.
//
// // - Prevents strings fixed at translation time to be fixed again
// fmt = fmt.replace("''", "'");
// // - Replace ' with the escaped version ''
// fmt = fmt.replace("'", "''");
//
// return MessageFormat.format(fmt, args);
// }
//
// /**
// * Does nothing.
// * <p/>
// * This method is an hack to extract words with gettext tool.
// */
// protected static void unusedStrings() {
// // These phrases are defined in the "platform.txt".
// _("Arduino AVR Boards");
// _("Arduino ARM (32-bits) Boards");
//
// // This word is defined in the "boards.txt".
// _("Processor");
// }
// }
// Path: app/src/processing/app/debug/TargetPackage.java
import processing.app.I18n;
import processing.app.helpers.filefilters.OnlyDirs;
import static processing.app.I18n._;
import java.io.File;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
TargetPackage - Represents a hardware package
Part of the Arduino project - http://www.arduino.cc/
Copyright (c) 2011 Cristian Maglie
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id$
*/
package processing.app.debug;
public class TargetPackage {
private String id;
Map<String, TargetPlatform> platforms = new LinkedHashMap<String, TargetPlatform>();
public TargetPackage(String _id, File _folder) throws TargetPlatformException {
id = _id;
File[] folders = _folder.listFiles(new OnlyDirs());
if (folders == null)
return;
for (File subFolder : folders) {
if (!subFolder.exists() || !subFolder.canRead())
continue;
String arch = subFolder.getName();
try {
TargetPlatform platform = new TargetPlatform(arch, subFolder, this);
platforms.put(arch, platform);
} catch (TargetPlatformException e) {
System.out.println(e.getMessage());
}
}
if (platforms.size() == 0) {
throw new TargetPlatformException(I18n
|
.format(_("No valid hardware definitions found in folder {0}."),
|
flutterwireless/ArduinoCodebase
|
app/src/processing/app/Serial.java
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
|
import java.io.*;
import java.util.*;
import processing.app.debug.MessageConsumer;
import static processing.app.I18n._;
import gnu.io.*;
|
public Serial(String iname, int irate) throws SerialException {
this(iname, irate, Preferences.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue());
}
public Serial(String iname) throws SerialException {
this(iname, Preferences.getInteger("serial.debug_rate"),
Preferences.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue());
}
public static boolean touchPort(String iname, int irate) throws SerialException {
SerialPort port;
boolean result = false;
try {
@SuppressWarnings("unchecked")
Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId = portList.nextElement();
if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
port = (SerialPort) portId.open("tap", 2000);
port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
port.close();
result = true;
}
}
} catch (PortInUseException e) {
throw new SerialException(
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
// Path: app/src/processing/app/Serial.java
import java.io.*;
import java.util.*;
import processing.app.debug.MessageConsumer;
import static processing.app.I18n._;
import gnu.io.*;
public Serial(String iname, int irate) throws SerialException {
this(iname, irate, Preferences.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue());
}
public Serial(String iname) throws SerialException {
this(iname, Preferences.getInteger("serial.debug_rate"),
Preferences.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue());
}
public static boolean touchPort(String iname, int irate) throws SerialException {
SerialPort port;
boolean result = false;
try {
@SuppressWarnings("unchecked")
Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId = portList.nextElement();
if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
port = (SerialPort) portId.open("tap", 2000);
port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
port.close();
result = true;
}
}
} catch (PortInUseException e) {
throw new SerialException(
|
I18n.format(_("Serial port ''{0}'' already in use. Try quitting any programs that may be using it."), iname)
|
flutterwireless/ArduinoCodebase
|
app/test/processing/app/preproc/PdePreprocessorTest.java
|
// Path: app/src/processing/app/helpers/FileUtils.java
// public class FileUtils {
//
// private static final List<String> SOURCE_CONTROL_FOLDERS = Arrays.asList("CVS", "RCS", ".git", ".svn", ".hg", ".bzr");
// private static final Pattern BACKSLASH = Pattern.compile("\\\\");
//
// /**
// * Checks, whether the child directory is a subdirectory of the base directory.
// *
// * @param base the base directory.
// * @param child the suspected child directory.
// * @return true, if the child is a subdirectory of the base directory.
// */
// public static boolean isSubDirectory(File base, File child) {
// try {
// base = base.getCanonicalFile();
// child = child.getCanonicalFile();
// } catch (IOException e) {
// return false;
// }
//
// File parentFile = child;
// while (parentFile != null) {
// if (base.equals(parentFile)) {
// return true;
// }
// parentFile = parentFile.getParentFile();
// }
// return false;
// }
//
// public static void copyFile(File source, File dest) throws IOException {
// FileInputStream fis = null;
// FileOutputStream fos = null;
// try {
// fis = new FileInputStream(source);
// fos = new FileOutputStream(dest);
// byte[] buf = new byte[4096];
// int readBytes = -1;
// while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
// fos.write(buf, 0, readBytes);
// }
// } finally {
// if (fis != null) {
// fis.close();
// }
// if (fos != null) {
// fos.close();
// }
// }
// }
//
// public static void copy(File sourceFolder, File destFolder) throws IOException {
// for (File file : sourceFolder.listFiles()) {
// File destFile = new File(destFolder, file.getName());
// if (file.isDirectory()) {
// if (!destFile.mkdir()) {
// throw new IOException("Unable to create folder: " + destFile);
// }
// copy(file, destFile);
// } else {
// copyFile(file, destFile);
// }
// }
// }
//
// public static void recursiveDelete(File file) {
// if (file == null) {
// return;
// }
// if (file.isDirectory()) {
// for (File current : file.listFiles()) {
// if (current.isDirectory()) {
// recursiveDelete(current);
// } else {
// current.delete();
// }
// }
// }
// file.delete();
// }
//
// public static File createTempFolder() throws IOException {
// File tmpFolder = new File(System.getProperty("java.io.tmpdir"), "arduino_" + new Random().nextInt(1000000));
// if (!tmpFolder.mkdir()) {
// throw new IOException("Unable to create temp folder " + tmpFolder);
// }
// return tmpFolder;
// }
//
// //
// // Compute relative path to "target" from a directory "origin".
// //
// // If "origin" is not absolute, it is relative from the current directory.
// // If "target" is not absolute, it is relative from "origin".
// //
// // by Shigeru KANEMOTO at SWITCHSCIENCE.
// //
// public static String relativePath(String origin, String target) {
// try {
// origin = (new File(origin)).getCanonicalPath();
// File targetFile = new File(target);
// if (targetFile.isAbsolute())
// target = targetFile.getCanonicalPath();
// else
// target = (new File(origin, target)).getCanonicalPath();
// } catch (IOException e) {
// return null;
// }
//
// if (origin.equals(target)) {
// // origin and target is identical.
// return ".";
// }
//
// if (origin.equals(File.separator)) {
// // origin is root.
// return "." + target;
// }
//
// String prefix = "";
// String root = File.separator;
//
// if (System.getProperty("os.name").indexOf("Windows") != -1) {
// if (origin.startsWith("\\\\") || target.startsWith("\\\\")) {
// // Windows UNC path not supported.
// return null;
// }
//
// char originLetter = origin.charAt(0);
// char targetLetter = target.charAt(0);
// if (Character.isLetter(originLetter) && Character.isLetter(targetLetter)) {
// // Windows only
// if (originLetter != targetLetter) {
// // Drive letters differ
// return null;
// }
// }
//
// prefix = "" + originLetter + ':';
// root = prefix + File.separator;
// }
//
// String relative = "";
// while (!target.startsWith(origin + File.separator)) {
// origin = (new File(origin)).getParent();
// if (origin.equals(root))
// origin = prefix;
// relative += "..";
// relative += File.separator;
// }
//
// return relative + target.substring(origin.length() + 1);
// }
//
// public static String getLinuxPathFrom(File file) {
// return BACKSLASH.matcher(file.getAbsolutePath()).replaceAll("/");
// }
//
// public static boolean isSCCSOrHiddenFile(File file) {
// return file.isHidden() || file.getName().charAt(0) == '.' || (file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName()));
// }
//
// public static String readFileToString(File file) throws IOException {
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
// StringBuilder sb = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// sb.append(line).append("\n");
// }
// return sb.toString();
// } finally {
// if (reader != null) {
// try {
// reader.close();
// } catch (IOException e) {
// // noop
// }
// }
// }
// }
// }
|
import org.junit.Test;
import processing.app.helpers.FileUtils;
import java.io.File;
import static org.junit.Assert.assertEquals;
|
package processing.app.preproc;
public class PdePreprocessorTest {
@Test
public void testSourceWithQuoteAndDoubleQuotesEscapedAndFinalQuoteShouldNotRaiseException() throws Exception {
|
// Path: app/src/processing/app/helpers/FileUtils.java
// public class FileUtils {
//
// private static final List<String> SOURCE_CONTROL_FOLDERS = Arrays.asList("CVS", "RCS", ".git", ".svn", ".hg", ".bzr");
// private static final Pattern BACKSLASH = Pattern.compile("\\\\");
//
// /**
// * Checks, whether the child directory is a subdirectory of the base directory.
// *
// * @param base the base directory.
// * @param child the suspected child directory.
// * @return true, if the child is a subdirectory of the base directory.
// */
// public static boolean isSubDirectory(File base, File child) {
// try {
// base = base.getCanonicalFile();
// child = child.getCanonicalFile();
// } catch (IOException e) {
// return false;
// }
//
// File parentFile = child;
// while (parentFile != null) {
// if (base.equals(parentFile)) {
// return true;
// }
// parentFile = parentFile.getParentFile();
// }
// return false;
// }
//
// public static void copyFile(File source, File dest) throws IOException {
// FileInputStream fis = null;
// FileOutputStream fos = null;
// try {
// fis = new FileInputStream(source);
// fos = new FileOutputStream(dest);
// byte[] buf = new byte[4096];
// int readBytes = -1;
// while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
// fos.write(buf, 0, readBytes);
// }
// } finally {
// if (fis != null) {
// fis.close();
// }
// if (fos != null) {
// fos.close();
// }
// }
// }
//
// public static void copy(File sourceFolder, File destFolder) throws IOException {
// for (File file : sourceFolder.listFiles()) {
// File destFile = new File(destFolder, file.getName());
// if (file.isDirectory()) {
// if (!destFile.mkdir()) {
// throw new IOException("Unable to create folder: " + destFile);
// }
// copy(file, destFile);
// } else {
// copyFile(file, destFile);
// }
// }
// }
//
// public static void recursiveDelete(File file) {
// if (file == null) {
// return;
// }
// if (file.isDirectory()) {
// for (File current : file.listFiles()) {
// if (current.isDirectory()) {
// recursiveDelete(current);
// } else {
// current.delete();
// }
// }
// }
// file.delete();
// }
//
// public static File createTempFolder() throws IOException {
// File tmpFolder = new File(System.getProperty("java.io.tmpdir"), "arduino_" + new Random().nextInt(1000000));
// if (!tmpFolder.mkdir()) {
// throw new IOException("Unable to create temp folder " + tmpFolder);
// }
// return tmpFolder;
// }
//
// //
// // Compute relative path to "target" from a directory "origin".
// //
// // If "origin" is not absolute, it is relative from the current directory.
// // If "target" is not absolute, it is relative from "origin".
// //
// // by Shigeru KANEMOTO at SWITCHSCIENCE.
// //
// public static String relativePath(String origin, String target) {
// try {
// origin = (new File(origin)).getCanonicalPath();
// File targetFile = new File(target);
// if (targetFile.isAbsolute())
// target = targetFile.getCanonicalPath();
// else
// target = (new File(origin, target)).getCanonicalPath();
// } catch (IOException e) {
// return null;
// }
//
// if (origin.equals(target)) {
// // origin and target is identical.
// return ".";
// }
//
// if (origin.equals(File.separator)) {
// // origin is root.
// return "." + target;
// }
//
// String prefix = "";
// String root = File.separator;
//
// if (System.getProperty("os.name").indexOf("Windows") != -1) {
// if (origin.startsWith("\\\\") || target.startsWith("\\\\")) {
// // Windows UNC path not supported.
// return null;
// }
//
// char originLetter = origin.charAt(0);
// char targetLetter = target.charAt(0);
// if (Character.isLetter(originLetter) && Character.isLetter(targetLetter)) {
// // Windows only
// if (originLetter != targetLetter) {
// // Drive letters differ
// return null;
// }
// }
//
// prefix = "" + originLetter + ':';
// root = prefix + File.separator;
// }
//
// String relative = "";
// while (!target.startsWith(origin + File.separator)) {
// origin = (new File(origin)).getParent();
// if (origin.equals(root))
// origin = prefix;
// relative += "..";
// relative += File.separator;
// }
//
// return relative + target.substring(origin.length() + 1);
// }
//
// public static String getLinuxPathFrom(File file) {
// return BACKSLASH.matcher(file.getAbsolutePath()).replaceAll("/");
// }
//
// public static boolean isSCCSOrHiddenFile(File file) {
// return file.isHidden() || file.getName().charAt(0) == '.' || (file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName()));
// }
//
// public static String readFileToString(File file) throws IOException {
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
// StringBuilder sb = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// sb.append(line).append("\n");
// }
// return sb.toString();
// } finally {
// if (reader != null) {
// try {
// reader.close();
// } catch (IOException e) {
// // noop
// }
// }
// }
// }
// }
// Path: app/test/processing/app/preproc/PdePreprocessorTest.java
import org.junit.Test;
import processing.app.helpers.FileUtils;
import java.io.File;
import static org.junit.Assert.assertEquals;
package processing.app.preproc;
public class PdePreprocessorTest {
@Test
public void testSourceWithQuoteAndDoubleQuotesEscapedAndFinalQuoteShouldNotRaiseException() throws Exception {
|
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("RemoteCallLogger_v1e0.ino").getFile()));
|
flutterwireless/ArduinoCodebase
|
app/src/processing/app/EditorStatus.java
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
|
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import static processing.app.I18n._;
|
if (c == KeyEvent.VK_ENTER) { // accept the input
String answer = editField.getText();
editor.getSketch().nameCode(answer);
unedit();
event.consume();
// easier to test the affirmative case than the negative
} else if ((c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE) ||
(c == KeyEvent.VK_RIGHT) ||
(c == KeyEvent.VK_LEFT) ||
(c == KeyEvent.VK_UP) ||
(c == KeyEvent.VK_DOWN) ||
(c == KeyEvent.VK_HOME) ||
(c == KeyEvent.VK_END) ||
(c == KeyEvent.VK_SHIFT)) {
// these events are ignored
/*
} else if (c == KeyEvent.VK_ESCAPE) {
unedit();
editor.toolbar.clear();
event.consume();
*/
} else if (c == KeyEvent.VK_SPACE) {
String t = editField.getText();
int start = editField.getSelectionStart();
int end = editField.getSelectionEnd();
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
// Path: app/src/processing/app/EditorStatus.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import static processing.app.I18n._;
if (c == KeyEvent.VK_ENTER) { // accept the input
String answer = editField.getText();
editor.getSketch().nameCode(answer);
unedit();
event.consume();
// easier to test the affirmative case than the negative
} else if ((c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE) ||
(c == KeyEvent.VK_RIGHT) ||
(c == KeyEvent.VK_LEFT) ||
(c == KeyEvent.VK_UP) ||
(c == KeyEvent.VK_DOWN) ||
(c == KeyEvent.VK_HOME) ||
(c == KeyEvent.VK_END) ||
(c == KeyEvent.VK_SHIFT)) {
// these events are ignored
/*
} else if (c == KeyEvent.VK_ESCAPE) {
unedit();
editor.toolbar.clear();
event.consume();
*/
} else if (c == KeyEvent.VK_SPACE) {
String t = editField.getText();
int start = editField.getSelectionStart();
int end = editField.getSelectionEnd();
|
editField.setText(t.substring(0, start) + "_" +
|
flutterwireless/ArduinoCodebase
|
app/src/processing/app/EditorConsole.java
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
|
import java.util.*;
import static processing.app.I18n._;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
|
int sizeFudge = 6; //10; // unclear why this is necessary, but it is
setPreferredSize(new Dimension(1024, (height * lines) + sizeFudge));
setMinimumSize(new Dimension(1024, (height * 4) + sizeFudge));
if (systemOut == null) {
systemOut = System.out;
systemErr = System.err;
// Create a temporary folder which will have a randomized name. Has to
// be randomized otherwise another instance of Processing (or one of its
// sister IDEs) might collide with the file causing permissions problems.
// The files and folders are not deleted on exit because they may be
// needed for debugging or bug reporting.
tempFolder = Base.createTempFolder("console");
tempFolder.deleteOnExit();
try {
String outFileName = Preferences.get("console.output.file");
if (outFileName != null) {
outFile = new File(tempFolder, outFileName);
outFile.deleteOnExit();
stdoutFile = new FileOutputStream(outFile);
}
String errFileName = Preferences.get("console.error.file");
if (errFileName != null) {
errFile = new File(tempFolder, errFileName);
errFile.deleteOnExit();
stderrFile = new FileOutputStream(errFile);
}
} catch (IOException e) {
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
// Path: app/src/processing/app/EditorConsole.java
import java.util.*;
import static processing.app.I18n._;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
int sizeFudge = 6; //10; // unclear why this is necessary, but it is
setPreferredSize(new Dimension(1024, (height * lines) + sizeFudge));
setMinimumSize(new Dimension(1024, (height * 4) + sizeFudge));
if (systemOut == null) {
systemOut = System.out;
systemErr = System.err;
// Create a temporary folder which will have a randomized name. Has to
// be randomized otherwise another instance of Processing (or one of its
// sister IDEs) might collide with the file causing permissions problems.
// The files and folders are not deleted on exit because they may be
// needed for debugging or bug reporting.
tempFolder = Base.createTempFolder("console");
tempFolder.deleteOnExit();
try {
String outFileName = Preferences.get("console.output.file");
if (outFileName != null) {
outFile = new File(tempFolder, outFileName);
outFile.deleteOnExit();
stdoutFile = new FileOutputStream(outFile);
}
String errFileName = Preferences.get("console.error.file");
if (errFileName != null) {
errFile = new File(tempFolder, errFileName);
errFile.deleteOnExit();
stderrFile = new FileOutputStream(errFile);
}
} catch (IOException e) {
|
Base.showWarning(_("Console Error"),
|
flutterwireless/ArduinoCodebase
|
app/src/processing/app/SerialMonitor.java
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
|
import cc.arduino.packages.BoardPort;
import processing.core.PApplet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static processing.app.I18n._;
|
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
public class SerialMonitor extends AbstractMonitor {
private final String port;
private Serial serial;
private int serialRate;
public SerialMonitor(BoardPort port) {
super(port.getLabel());
this.port = port.getAddress();
serialRate = Preferences.getInteger("serial.debug_rate");
|
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
// String res;
// try {
// res = i18n.getString(s);
// } catch (MissingResourceException e) {
// res = s;
// }
//
// // The single % is the arguments selector in .PO files.
// // We must put double %% inside the translations to avoid
// // getting .PO processing in the way.
// res = res.replace("%%", "%");
//
// return res;
// }
// Path: app/src/processing/app/SerialMonitor.java
import cc.arduino.packages.BoardPort;
import processing.core.PApplet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static processing.app.I18n._;
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
public class SerialMonitor extends AbstractMonitor {
private final String port;
private Serial serial;
private int serialRate;
public SerialMonitor(BoardPort port) {
super(port.getLabel());
this.port = port.getAddress();
serialRate = Preferences.getInteger("serial.debug_rate");
|
serialRates.setSelectedItem(serialRate + " " + _("baud"));
|
Kjos/HoloKilo
|
holokilo/src/main/java/net/kajos/holokilo/GLSurfaceView.java
|
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Tracker.java
// public abstract class Tracker {
// protected Matrix3x3 initial = new Matrix3x3();
//
// protected Matrix3x3 flip = new Matrix3x3();
//
// protected Matrix3x3 tmp = new Matrix3x3();
// protected Matrix3x3 tmp2 = new Matrix3x3();
// protected Matrix3x3 tmp3 = new Matrix3x3();
//
// private Matrix3x3 base = new Matrix3x3();
//
// public abstract void init();
//
// public void setBaseRotation() {
// getLastHeadView(base);
// }
//
// public void getCorrectedHeadView(Matrix3x3 headView, Matrix3x3 headViewRaw) {
// getLastHeadView(tmp2);
// headViewRaw.set(tmp2);
// tmp2.transpose();
// Matrix3x3.mult(base, tmp2, tmp3);
// Matrix3x3.mult(tmp3, initial, tmp);
// headView.set(tmp);
// }
//
// public Matrix3x3 differenceHeadView(Matrix3x3 a, Matrix3x3 b) {
// a.invert(tmp);
// tmp2.set(b);
// Matrix3x3.mult(tmp, tmp2, tmp3);
// return tmp3;
// }
//
// public abstract void getLastHeadView(Matrix3x3 headView);
//
// public abstract void stopTracking() ;
// public abstract void startTracking();
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/DummyTracker.java
// public class DummyTracker extends Tracker {
// @Override
// public void init() {
//
// }
//
// @Override
// public void getLastHeadView(Matrix3x3 headView) {
// headView.setIdentity();
// }
//
// @Override
// public void stopTracking() {
//
// }
//
// @Override
// public void startTracking() {
//
// }
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/GoogleHeadTracker.java
// public class GoogleHeadTracker extends Tracker
// {
// // Tracker that wraps around Google Cardboard's headtracker.
//
// private HeadTracker headTracker;
// private LowPassFilter[] filters = new LowPassFilter[16];
//
// public GoogleHeadTracker(SensorEventProvider sensorEventProvider, Clock clock, Display display) {
// headTracker = new HeadTracker(sensorEventProvider, clock, display);
// for (int i = 0; i < 16; i++) {
// filters[i] = new LowPassFilter(Config.LP_FOR_GYRO);
// }
// }
//
// public static GoogleHeadTracker createFromContext(Context context) {
// SensorManager sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
// Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// GoogleHeadTracker result = new GoogleHeadTracker(new DeviceSensorLooper(sensorManager), new SystemClock(), display);
// result.init();
// return result;
// }
//
// public void init() {
// tmp.setToRotation(new Vector3(1, 0, 0), -90);
// flip = new Matrix3x3(1,0,0, 0,-1,0, 0,0,1);
// Matrix3x3.mult(tmp, flip, initial);
// }
//
// float matrix[] = new float[16];
// public void getLastHeadView(Matrix3x3 headView) {
// headTracker.getLastHeadView(matrix, 0);
// for (int i = 0; i < 16; i++) {
// matrix[i] = filters[i].get(matrix[i]);
// }
// for (int c = 0; c < 3; c++)
// for (int r = 0; r < 3; r++) {
// headView.set(r, c, matrix[c * 4 + r]);
// }
// }
//
// @Override
// public void stopTracking() {
// headTracker.stopTracking();
// }
//
// @Override
// public void startTracking() {
// headTracker.startTracking();
// }
// }
|
import android.content.Context;
import android.view.MotionEvent;
import net.kajos.holokilo.Orientation.Tracker;
import net.kajos.holokilo.Orientation.Trackers.DummyTracker;
import net.kajos.holokilo.Orientation.Trackers.GoogleHeadTracker;
|
package net.kajos.holokilo;
public class GLSurfaceView extends android.opengl.GLSurfaceView
{
public GLRenderer renderer = null;
|
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Tracker.java
// public abstract class Tracker {
// protected Matrix3x3 initial = new Matrix3x3();
//
// protected Matrix3x3 flip = new Matrix3x3();
//
// protected Matrix3x3 tmp = new Matrix3x3();
// protected Matrix3x3 tmp2 = new Matrix3x3();
// protected Matrix3x3 tmp3 = new Matrix3x3();
//
// private Matrix3x3 base = new Matrix3x3();
//
// public abstract void init();
//
// public void setBaseRotation() {
// getLastHeadView(base);
// }
//
// public void getCorrectedHeadView(Matrix3x3 headView, Matrix3x3 headViewRaw) {
// getLastHeadView(tmp2);
// headViewRaw.set(tmp2);
// tmp2.transpose();
// Matrix3x3.mult(base, tmp2, tmp3);
// Matrix3x3.mult(tmp3, initial, tmp);
// headView.set(tmp);
// }
//
// public Matrix3x3 differenceHeadView(Matrix3x3 a, Matrix3x3 b) {
// a.invert(tmp);
// tmp2.set(b);
// Matrix3x3.mult(tmp, tmp2, tmp3);
// return tmp3;
// }
//
// public abstract void getLastHeadView(Matrix3x3 headView);
//
// public abstract void stopTracking() ;
// public abstract void startTracking();
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/DummyTracker.java
// public class DummyTracker extends Tracker {
// @Override
// public void init() {
//
// }
//
// @Override
// public void getLastHeadView(Matrix3x3 headView) {
// headView.setIdentity();
// }
//
// @Override
// public void stopTracking() {
//
// }
//
// @Override
// public void startTracking() {
//
// }
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/GoogleHeadTracker.java
// public class GoogleHeadTracker extends Tracker
// {
// // Tracker that wraps around Google Cardboard's headtracker.
//
// private HeadTracker headTracker;
// private LowPassFilter[] filters = new LowPassFilter[16];
//
// public GoogleHeadTracker(SensorEventProvider sensorEventProvider, Clock clock, Display display) {
// headTracker = new HeadTracker(sensorEventProvider, clock, display);
// for (int i = 0; i < 16; i++) {
// filters[i] = new LowPassFilter(Config.LP_FOR_GYRO);
// }
// }
//
// public static GoogleHeadTracker createFromContext(Context context) {
// SensorManager sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
// Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// GoogleHeadTracker result = new GoogleHeadTracker(new DeviceSensorLooper(sensorManager), new SystemClock(), display);
// result.init();
// return result;
// }
//
// public void init() {
// tmp.setToRotation(new Vector3(1, 0, 0), -90);
// flip = new Matrix3x3(1,0,0, 0,-1,0, 0,0,1);
// Matrix3x3.mult(tmp, flip, initial);
// }
//
// float matrix[] = new float[16];
// public void getLastHeadView(Matrix3x3 headView) {
// headTracker.getLastHeadView(matrix, 0);
// for (int i = 0; i < 16; i++) {
// matrix[i] = filters[i].get(matrix[i]);
// }
// for (int c = 0; c < 3; c++)
// for (int r = 0; r < 3; r++) {
// headView.set(r, c, matrix[c * 4 + r]);
// }
// }
//
// @Override
// public void stopTracking() {
// headTracker.stopTracking();
// }
//
// @Override
// public void startTracking() {
// headTracker.startTracking();
// }
// }
// Path: holokilo/src/main/java/net/kajos/holokilo/GLSurfaceView.java
import android.content.Context;
import android.view.MotionEvent;
import net.kajos.holokilo.Orientation.Tracker;
import net.kajos.holokilo.Orientation.Trackers.DummyTracker;
import net.kajos.holokilo.Orientation.Trackers.GoogleHeadTracker;
package net.kajos.holokilo;
public class GLSurfaceView extends android.opengl.GLSurfaceView
{
public GLRenderer renderer = null;
|
public GLSurfaceView(Context context, Tracker tracker)
|
Kjos/HoloKilo
|
holokilo/src/main/java/net/kajos/holokilo/GLSurfaceView.java
|
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Tracker.java
// public abstract class Tracker {
// protected Matrix3x3 initial = new Matrix3x3();
//
// protected Matrix3x3 flip = new Matrix3x3();
//
// protected Matrix3x3 tmp = new Matrix3x3();
// protected Matrix3x3 tmp2 = new Matrix3x3();
// protected Matrix3x3 tmp3 = new Matrix3x3();
//
// private Matrix3x3 base = new Matrix3x3();
//
// public abstract void init();
//
// public void setBaseRotation() {
// getLastHeadView(base);
// }
//
// public void getCorrectedHeadView(Matrix3x3 headView, Matrix3x3 headViewRaw) {
// getLastHeadView(tmp2);
// headViewRaw.set(tmp2);
// tmp2.transpose();
// Matrix3x3.mult(base, tmp2, tmp3);
// Matrix3x3.mult(tmp3, initial, tmp);
// headView.set(tmp);
// }
//
// public Matrix3x3 differenceHeadView(Matrix3x3 a, Matrix3x3 b) {
// a.invert(tmp);
// tmp2.set(b);
// Matrix3x3.mult(tmp, tmp2, tmp3);
// return tmp3;
// }
//
// public abstract void getLastHeadView(Matrix3x3 headView);
//
// public abstract void stopTracking() ;
// public abstract void startTracking();
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/DummyTracker.java
// public class DummyTracker extends Tracker {
// @Override
// public void init() {
//
// }
//
// @Override
// public void getLastHeadView(Matrix3x3 headView) {
// headView.setIdentity();
// }
//
// @Override
// public void stopTracking() {
//
// }
//
// @Override
// public void startTracking() {
//
// }
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/GoogleHeadTracker.java
// public class GoogleHeadTracker extends Tracker
// {
// // Tracker that wraps around Google Cardboard's headtracker.
//
// private HeadTracker headTracker;
// private LowPassFilter[] filters = new LowPassFilter[16];
//
// public GoogleHeadTracker(SensorEventProvider sensorEventProvider, Clock clock, Display display) {
// headTracker = new HeadTracker(sensorEventProvider, clock, display);
// for (int i = 0; i < 16; i++) {
// filters[i] = new LowPassFilter(Config.LP_FOR_GYRO);
// }
// }
//
// public static GoogleHeadTracker createFromContext(Context context) {
// SensorManager sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
// Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// GoogleHeadTracker result = new GoogleHeadTracker(new DeviceSensorLooper(sensorManager), new SystemClock(), display);
// result.init();
// return result;
// }
//
// public void init() {
// tmp.setToRotation(new Vector3(1, 0, 0), -90);
// flip = new Matrix3x3(1,0,0, 0,-1,0, 0,0,1);
// Matrix3x3.mult(tmp, flip, initial);
// }
//
// float matrix[] = new float[16];
// public void getLastHeadView(Matrix3x3 headView) {
// headTracker.getLastHeadView(matrix, 0);
// for (int i = 0; i < 16; i++) {
// matrix[i] = filters[i].get(matrix[i]);
// }
// for (int c = 0; c < 3; c++)
// for (int r = 0; r < 3; r++) {
// headView.set(r, c, matrix[c * 4 + r]);
// }
// }
//
// @Override
// public void stopTracking() {
// headTracker.stopTracking();
// }
//
// @Override
// public void startTracking() {
// headTracker.startTracking();
// }
// }
|
import android.content.Context;
import android.view.MotionEvent;
import net.kajos.holokilo.Orientation.Tracker;
import net.kajos.holokilo.Orientation.Trackers.DummyTracker;
import net.kajos.holokilo.Orientation.Trackers.GoogleHeadTracker;
|
package net.kajos.holokilo;
public class GLSurfaceView extends android.opengl.GLSurfaceView
{
public GLRenderer renderer = null;
public GLSurfaceView(Context context, Tracker tracker)
{
super(context);
setEGLContextClientVersion(2);
renderer = new GLRenderer(this, tracker);
setRenderer(renderer);
setRenderMode(Config.RENDER_WHEN_DIRTY ? android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY : android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
public GLSurfaceView(Context context)
{
super(context);
setEGLContextClientVersion(2);
// Initialize rotational tracker
// Dummytracker for stationary use
// Use Cardboardtracker for sensor fusion
|
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Tracker.java
// public abstract class Tracker {
// protected Matrix3x3 initial = new Matrix3x3();
//
// protected Matrix3x3 flip = new Matrix3x3();
//
// protected Matrix3x3 tmp = new Matrix3x3();
// protected Matrix3x3 tmp2 = new Matrix3x3();
// protected Matrix3x3 tmp3 = new Matrix3x3();
//
// private Matrix3x3 base = new Matrix3x3();
//
// public abstract void init();
//
// public void setBaseRotation() {
// getLastHeadView(base);
// }
//
// public void getCorrectedHeadView(Matrix3x3 headView, Matrix3x3 headViewRaw) {
// getLastHeadView(tmp2);
// headViewRaw.set(tmp2);
// tmp2.transpose();
// Matrix3x3.mult(base, tmp2, tmp3);
// Matrix3x3.mult(tmp3, initial, tmp);
// headView.set(tmp);
// }
//
// public Matrix3x3 differenceHeadView(Matrix3x3 a, Matrix3x3 b) {
// a.invert(tmp);
// tmp2.set(b);
// Matrix3x3.mult(tmp, tmp2, tmp3);
// return tmp3;
// }
//
// public abstract void getLastHeadView(Matrix3x3 headView);
//
// public abstract void stopTracking() ;
// public abstract void startTracking();
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/DummyTracker.java
// public class DummyTracker extends Tracker {
// @Override
// public void init() {
//
// }
//
// @Override
// public void getLastHeadView(Matrix3x3 headView) {
// headView.setIdentity();
// }
//
// @Override
// public void stopTracking() {
//
// }
//
// @Override
// public void startTracking() {
//
// }
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/GoogleHeadTracker.java
// public class GoogleHeadTracker extends Tracker
// {
// // Tracker that wraps around Google Cardboard's headtracker.
//
// private HeadTracker headTracker;
// private LowPassFilter[] filters = new LowPassFilter[16];
//
// public GoogleHeadTracker(SensorEventProvider sensorEventProvider, Clock clock, Display display) {
// headTracker = new HeadTracker(sensorEventProvider, clock, display);
// for (int i = 0; i < 16; i++) {
// filters[i] = new LowPassFilter(Config.LP_FOR_GYRO);
// }
// }
//
// public static GoogleHeadTracker createFromContext(Context context) {
// SensorManager sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
// Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// GoogleHeadTracker result = new GoogleHeadTracker(new DeviceSensorLooper(sensorManager), new SystemClock(), display);
// result.init();
// return result;
// }
//
// public void init() {
// tmp.setToRotation(new Vector3(1, 0, 0), -90);
// flip = new Matrix3x3(1,0,0, 0,-1,0, 0,0,1);
// Matrix3x3.mult(tmp, flip, initial);
// }
//
// float matrix[] = new float[16];
// public void getLastHeadView(Matrix3x3 headView) {
// headTracker.getLastHeadView(matrix, 0);
// for (int i = 0; i < 16; i++) {
// matrix[i] = filters[i].get(matrix[i]);
// }
// for (int c = 0; c < 3; c++)
// for (int r = 0; r < 3; r++) {
// headView.set(r, c, matrix[c * 4 + r]);
// }
// }
//
// @Override
// public void stopTracking() {
// headTracker.stopTracking();
// }
//
// @Override
// public void startTracking() {
// headTracker.startTracking();
// }
// }
// Path: holokilo/src/main/java/net/kajos/holokilo/GLSurfaceView.java
import android.content.Context;
import android.view.MotionEvent;
import net.kajos.holokilo.Orientation.Tracker;
import net.kajos.holokilo.Orientation.Trackers.DummyTracker;
import net.kajos.holokilo.Orientation.Trackers.GoogleHeadTracker;
package net.kajos.holokilo;
public class GLSurfaceView extends android.opengl.GLSurfaceView
{
public GLRenderer renderer = null;
public GLSurfaceView(Context context, Tracker tracker)
{
super(context);
setEGLContextClientVersion(2);
renderer = new GLRenderer(this, tracker);
setRenderer(renderer);
setRenderMode(Config.RENDER_WHEN_DIRTY ? android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY : android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
public GLSurfaceView(Context context)
{
super(context);
setEGLContextClientVersion(2);
// Initialize rotational tracker
// Dummytracker for stationary use
// Use Cardboardtracker for sensor fusion
|
Tracker tracker = Config.DUMMY_TRACKER ? new DummyTracker() : GoogleHeadTracker.createFromContext(context);
|
Kjos/HoloKilo
|
holokilo/src/main/java/net/kajos/holokilo/GLSurfaceView.java
|
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Tracker.java
// public abstract class Tracker {
// protected Matrix3x3 initial = new Matrix3x3();
//
// protected Matrix3x3 flip = new Matrix3x3();
//
// protected Matrix3x3 tmp = new Matrix3x3();
// protected Matrix3x3 tmp2 = new Matrix3x3();
// protected Matrix3x3 tmp3 = new Matrix3x3();
//
// private Matrix3x3 base = new Matrix3x3();
//
// public abstract void init();
//
// public void setBaseRotation() {
// getLastHeadView(base);
// }
//
// public void getCorrectedHeadView(Matrix3x3 headView, Matrix3x3 headViewRaw) {
// getLastHeadView(tmp2);
// headViewRaw.set(tmp2);
// tmp2.transpose();
// Matrix3x3.mult(base, tmp2, tmp3);
// Matrix3x3.mult(tmp3, initial, tmp);
// headView.set(tmp);
// }
//
// public Matrix3x3 differenceHeadView(Matrix3x3 a, Matrix3x3 b) {
// a.invert(tmp);
// tmp2.set(b);
// Matrix3x3.mult(tmp, tmp2, tmp3);
// return tmp3;
// }
//
// public abstract void getLastHeadView(Matrix3x3 headView);
//
// public abstract void stopTracking() ;
// public abstract void startTracking();
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/DummyTracker.java
// public class DummyTracker extends Tracker {
// @Override
// public void init() {
//
// }
//
// @Override
// public void getLastHeadView(Matrix3x3 headView) {
// headView.setIdentity();
// }
//
// @Override
// public void stopTracking() {
//
// }
//
// @Override
// public void startTracking() {
//
// }
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/GoogleHeadTracker.java
// public class GoogleHeadTracker extends Tracker
// {
// // Tracker that wraps around Google Cardboard's headtracker.
//
// private HeadTracker headTracker;
// private LowPassFilter[] filters = new LowPassFilter[16];
//
// public GoogleHeadTracker(SensorEventProvider sensorEventProvider, Clock clock, Display display) {
// headTracker = new HeadTracker(sensorEventProvider, clock, display);
// for (int i = 0; i < 16; i++) {
// filters[i] = new LowPassFilter(Config.LP_FOR_GYRO);
// }
// }
//
// public static GoogleHeadTracker createFromContext(Context context) {
// SensorManager sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
// Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// GoogleHeadTracker result = new GoogleHeadTracker(new DeviceSensorLooper(sensorManager), new SystemClock(), display);
// result.init();
// return result;
// }
//
// public void init() {
// tmp.setToRotation(new Vector3(1, 0, 0), -90);
// flip = new Matrix3x3(1,0,0, 0,-1,0, 0,0,1);
// Matrix3x3.mult(tmp, flip, initial);
// }
//
// float matrix[] = new float[16];
// public void getLastHeadView(Matrix3x3 headView) {
// headTracker.getLastHeadView(matrix, 0);
// for (int i = 0; i < 16; i++) {
// matrix[i] = filters[i].get(matrix[i]);
// }
// for (int c = 0; c < 3; c++)
// for (int r = 0; r < 3; r++) {
// headView.set(r, c, matrix[c * 4 + r]);
// }
// }
//
// @Override
// public void stopTracking() {
// headTracker.stopTracking();
// }
//
// @Override
// public void startTracking() {
// headTracker.startTracking();
// }
// }
|
import android.content.Context;
import android.view.MotionEvent;
import net.kajos.holokilo.Orientation.Tracker;
import net.kajos.holokilo.Orientation.Trackers.DummyTracker;
import net.kajos.holokilo.Orientation.Trackers.GoogleHeadTracker;
|
package net.kajos.holokilo;
public class GLSurfaceView extends android.opengl.GLSurfaceView
{
public GLRenderer renderer = null;
public GLSurfaceView(Context context, Tracker tracker)
{
super(context);
setEGLContextClientVersion(2);
renderer = new GLRenderer(this, tracker);
setRenderer(renderer);
setRenderMode(Config.RENDER_WHEN_DIRTY ? android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY : android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
public GLSurfaceView(Context context)
{
super(context);
setEGLContextClientVersion(2);
// Initialize rotational tracker
// Dummytracker for stationary use
// Use Cardboardtracker for sensor fusion
|
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Tracker.java
// public abstract class Tracker {
// protected Matrix3x3 initial = new Matrix3x3();
//
// protected Matrix3x3 flip = new Matrix3x3();
//
// protected Matrix3x3 tmp = new Matrix3x3();
// protected Matrix3x3 tmp2 = new Matrix3x3();
// protected Matrix3x3 tmp3 = new Matrix3x3();
//
// private Matrix3x3 base = new Matrix3x3();
//
// public abstract void init();
//
// public void setBaseRotation() {
// getLastHeadView(base);
// }
//
// public void getCorrectedHeadView(Matrix3x3 headView, Matrix3x3 headViewRaw) {
// getLastHeadView(tmp2);
// headViewRaw.set(tmp2);
// tmp2.transpose();
// Matrix3x3.mult(base, tmp2, tmp3);
// Matrix3x3.mult(tmp3, initial, tmp);
// headView.set(tmp);
// }
//
// public Matrix3x3 differenceHeadView(Matrix3x3 a, Matrix3x3 b) {
// a.invert(tmp);
// tmp2.set(b);
// Matrix3x3.mult(tmp, tmp2, tmp3);
// return tmp3;
// }
//
// public abstract void getLastHeadView(Matrix3x3 headView);
//
// public abstract void stopTracking() ;
// public abstract void startTracking();
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/DummyTracker.java
// public class DummyTracker extends Tracker {
// @Override
// public void init() {
//
// }
//
// @Override
// public void getLastHeadView(Matrix3x3 headView) {
// headView.setIdentity();
// }
//
// @Override
// public void stopTracking() {
//
// }
//
// @Override
// public void startTracking() {
//
// }
// }
//
// Path: holokilo/src/main/java/net/kajos/holokilo/Orientation/Trackers/GoogleHeadTracker.java
// public class GoogleHeadTracker extends Tracker
// {
// // Tracker that wraps around Google Cardboard's headtracker.
//
// private HeadTracker headTracker;
// private LowPassFilter[] filters = new LowPassFilter[16];
//
// public GoogleHeadTracker(SensorEventProvider sensorEventProvider, Clock clock, Display display) {
// headTracker = new HeadTracker(sensorEventProvider, clock, display);
// for (int i = 0; i < 16; i++) {
// filters[i] = new LowPassFilter(Config.LP_FOR_GYRO);
// }
// }
//
// public static GoogleHeadTracker createFromContext(Context context) {
// SensorManager sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
// Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// GoogleHeadTracker result = new GoogleHeadTracker(new DeviceSensorLooper(sensorManager), new SystemClock(), display);
// result.init();
// return result;
// }
//
// public void init() {
// tmp.setToRotation(new Vector3(1, 0, 0), -90);
// flip = new Matrix3x3(1,0,0, 0,-1,0, 0,0,1);
// Matrix3x3.mult(tmp, flip, initial);
// }
//
// float matrix[] = new float[16];
// public void getLastHeadView(Matrix3x3 headView) {
// headTracker.getLastHeadView(matrix, 0);
// for (int i = 0; i < 16; i++) {
// matrix[i] = filters[i].get(matrix[i]);
// }
// for (int c = 0; c < 3; c++)
// for (int r = 0; r < 3; r++) {
// headView.set(r, c, matrix[c * 4 + r]);
// }
// }
//
// @Override
// public void stopTracking() {
// headTracker.stopTracking();
// }
//
// @Override
// public void startTracking() {
// headTracker.startTracking();
// }
// }
// Path: holokilo/src/main/java/net/kajos/holokilo/GLSurfaceView.java
import android.content.Context;
import android.view.MotionEvent;
import net.kajos.holokilo.Orientation.Tracker;
import net.kajos.holokilo.Orientation.Trackers.DummyTracker;
import net.kajos.holokilo.Orientation.Trackers.GoogleHeadTracker;
package net.kajos.holokilo;
public class GLSurfaceView extends android.opengl.GLSurfaceView
{
public GLRenderer renderer = null;
public GLSurfaceView(Context context, Tracker tracker)
{
super(context);
setEGLContextClientVersion(2);
renderer = new GLRenderer(this, tracker);
setRenderer(renderer);
setRenderMode(Config.RENDER_WHEN_DIRTY ? android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY : android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
public GLSurfaceView(Context context)
{
super(context);
setEGLContextClientVersion(2);
// Initialize rotational tracker
// Dummytracker for stationary use
// Use Cardboardtracker for sensor fusion
|
Tracker tracker = Config.DUMMY_TRACKER ? new DummyTracker() : GoogleHeadTracker.createFromContext(context);
|
AndroidStudioTranslate/Android-Studio-Translate-Tool
|
src/test/Google.java
|
// Path: src/translation/Post.java
// public class Post {
//
// public static String http(String url, Map<String, String> params) {
// URL u = null;
// HttpURLConnection con = null;
// StringBuffer buffer = new StringBuffer();
// //构建请求参数
// StringBuffer sb = new StringBuffer();
// if (params != null) {
// for (Entry<String, String> e : params.entrySet()) {
// sb.append(e.getKey());
// sb.append("=");
// sb.append(e.getValue());
// //sb.append("&");//多个参数时需要加上
// }
// sb.substring(0, sb.length() - 1);
// }
// // System.out.println("send_url:" + url);
// // System.out.println("send_data:" + sb.toString());
// //尝试发送请求
// try {
// u = new URL(url);
// con = (HttpURLConnection) u.openConnection();
// con.setRequestMethod("POST");
// con.setDoOutput(true);
// con.setDoInput(true);
// con.setUseCaches(false);
// con.setReadTimeout(3000);
// con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream(), "UTF-8");
// osw.write(sb.toString());
// osw.flush();
// osw.close();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (con != null) {
// con.disconnect();
// }
// }
//
// //读取返回内容
// try {
// if (con.getResponseCode() == 200) {
// BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
// String temp;
// while ((temp = br.readLine()) != null) {
// buffer.append(temp);
// buffer.append("\n");
// }
// } else {
// buffer.append(con.getResponseCode());
// }
// //System.out.println(con.getResponseCode() + "");
// } catch (Exception e) {
// e.printStackTrace();
// }
// return buffer.toString();
// }
//
// /**
// * 获取翻译结果
// *
// * @param tvalue 需要翻译的中文字符串
// * @return
// */
// public static String tg(String translate_site, String tvalue) {
// Map<String, String> map = new HashMap<String, String>();;
// map.put("origin", tvalue);
// return http(translate_site, map).trim();
// }
//
// /**
// * 获取翻译结果(比用JSON速度更快)
// *
// * @param tvalue 需要翻译的中文字符串
// * @return
// */
// public String tg1(String translate_site, String tvalue) {
// Map<String, String> map = new HashMap<String, String>();
// map.put("origin", tvalue);
// String tempt = WordsTransfer.unicodeToUtf8(http(translate_site, map).trim());
// tempt = tempt.substring(tempt.lastIndexOf(":") + 1, tempt.length() - 3).replaceAll("\"", "");
// return tempt;
// }
// // public static void main(String[] args) {
// // Map<String, String> map = new HashMap<String, String>();;
// // map.put("q", "中国");
// // System.out.println(http("http://zhangwei911.duapp.com/TranslateGet.jsp", map).trim());
// // }
// }
|
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import translation.Post;
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;
/**
*
* @author vi
*/
public class Google {
public static void main(String[] args) {
String words = "this is a test!\nthis is a test!\nthis is a test!";
try {
Map<String, String> map = new HashMap<String, String>();
map.put("client", "t");
map.put("text", words);
map.put("sl", "en");
map.put("tl", "zh_CN");
|
// Path: src/translation/Post.java
// public class Post {
//
// public static String http(String url, Map<String, String> params) {
// URL u = null;
// HttpURLConnection con = null;
// StringBuffer buffer = new StringBuffer();
// //构建请求参数
// StringBuffer sb = new StringBuffer();
// if (params != null) {
// for (Entry<String, String> e : params.entrySet()) {
// sb.append(e.getKey());
// sb.append("=");
// sb.append(e.getValue());
// //sb.append("&");//多个参数时需要加上
// }
// sb.substring(0, sb.length() - 1);
// }
// // System.out.println("send_url:" + url);
// // System.out.println("send_data:" + sb.toString());
// //尝试发送请求
// try {
// u = new URL(url);
// con = (HttpURLConnection) u.openConnection();
// con.setRequestMethod("POST");
// con.setDoOutput(true);
// con.setDoInput(true);
// con.setUseCaches(false);
// con.setReadTimeout(3000);
// con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream(), "UTF-8");
// osw.write(sb.toString());
// osw.flush();
// osw.close();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (con != null) {
// con.disconnect();
// }
// }
//
// //读取返回内容
// try {
// if (con.getResponseCode() == 200) {
// BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
// String temp;
// while ((temp = br.readLine()) != null) {
// buffer.append(temp);
// buffer.append("\n");
// }
// } else {
// buffer.append(con.getResponseCode());
// }
// //System.out.println(con.getResponseCode() + "");
// } catch (Exception e) {
// e.printStackTrace();
// }
// return buffer.toString();
// }
//
// /**
// * 获取翻译结果
// *
// * @param tvalue 需要翻译的中文字符串
// * @return
// */
// public static String tg(String translate_site, String tvalue) {
// Map<String, String> map = new HashMap<String, String>();;
// map.put("origin", tvalue);
// return http(translate_site, map).trim();
// }
//
// /**
// * 获取翻译结果(比用JSON速度更快)
// *
// * @param tvalue 需要翻译的中文字符串
// * @return
// */
// public String tg1(String translate_site, String tvalue) {
// Map<String, String> map = new HashMap<String, String>();
// map.put("origin", tvalue);
// String tempt = WordsTransfer.unicodeToUtf8(http(translate_site, map).trim());
// tempt = tempt.substring(tempt.lastIndexOf(":") + 1, tempt.length() - 3).replaceAll("\"", "");
// return tempt;
// }
// // public static void main(String[] args) {
// // Map<String, String> map = new HashMap<String, String>();;
// // map.put("q", "中国");
// // System.out.println(http("http://zhangwei911.duapp.com/TranslateGet.jsp", map).trim());
// // }
// }
// Path: src/test/Google.java
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import translation.Post;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;
/**
*
* @author vi
*/
public class Google {
public static void main(String[] args) {
String words = "this is a test!\nthis is a test!\nthis is a test!";
try {
Map<String, String> map = new HashMap<String, String>();
map.put("client", "t");
map.put("text", words);
map.put("sl", "en");
map.put("tl", "zh_CN");
|
String dst=Post.http("http://translate.google.com/translate_a/t", map);
|
AndroidStudioTranslate/Android-Studio-Translate-Tool
|
src/translation/baidu/BaiDuTranslate.java
|
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String APP_ID = "";
//
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String SECURITY_KEY = "";
|
import static translation.baidu.BaiDuTranslateApiConfig.SECURITY_KEY;
import static translation.baidu.BaiDuTranslateApiConfig.APP_ID;
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package translation.baidu;
/**
*
* @author swtf
*/
public class BaiDuTranslate {
public static String translate(String query,String to){
|
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String APP_ID = "";
//
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String SECURITY_KEY = "";
// Path: src/translation/baidu/BaiDuTranslate.java
import static translation.baidu.BaiDuTranslateApiConfig.SECURITY_KEY;
import static translation.baidu.BaiDuTranslateApiConfig.APP_ID;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package translation.baidu;
/**
*
* @author swtf
*/
public class BaiDuTranslate {
public static String translate(String query,String to){
|
BaiDuTranslateApi api = new BaiDuTranslateApi(APP_ID, SECURITY_KEY);
|
AndroidStudioTranslate/Android-Studio-Translate-Tool
|
src/translation/baidu/BaiDuTranslate.java
|
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String APP_ID = "";
//
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String SECURITY_KEY = "";
|
import static translation.baidu.BaiDuTranslateApiConfig.SECURITY_KEY;
import static translation.baidu.BaiDuTranslateApiConfig.APP_ID;
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package translation.baidu;
/**
*
* @author swtf
*/
public class BaiDuTranslate {
public static String translate(String query,String to){
|
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String APP_ID = "";
//
// Path: src/translation/baidu/BaiDuTranslateApiConfig.java
// public static final String SECURITY_KEY = "";
// Path: src/translation/baidu/BaiDuTranslate.java
import static translation.baidu.BaiDuTranslateApiConfig.SECURITY_KEY;
import static translation.baidu.BaiDuTranslateApiConfig.APP_ID;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package translation.baidu;
/**
*
* @author swtf
*/
public class BaiDuTranslate {
public static String translate(String query,String to){
|
BaiDuTranslateApi api = new BaiDuTranslateApi(APP_ID, SECURITY_KEY);
|
ceefour/webdav-servlet
|
src/main/java/net/sf/webdav/locking/ResourceLocks.java
|
// Path: src/main/java/net/sf/webdav/ITransaction.java
// public interface ITransaction {
//
// Principal getPrincipal();
//
// }
//
// Path: src/main/java/net/sf/webdav/exceptions/LockFailedException.java
// public class LockFailedException extends WebdavException {
//
// public LockFailedException() {
// super();
// }
//
// public LockFailedException(String message) {
// super(message);
// }
//
// public LockFailedException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LockFailedException(Throwable cause) {
// super(cause);
// }
// }
|
import java.util.Enumeration;
import java.util.Hashtable;
import net.sf.webdav.ITransaction;
import net.sf.webdav.exceptions.LockFailedException;
|
/*
* Copyright 2005-2006 webdav-servlet group.
*
* 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 net.sf.webdav.locking;
/**
* simple locking management for concurrent data access, NOT the webdav locking.
* ( could that be used instead? )
*
* IT IS ACTUALLY USED FOR DOLOCK
*
* @author re
*/
public class ResourceLocks implements IResourceLocks {
private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory
.getLogger(ResourceLocks.class);
/**
* after creating this much LockedObjects, a cleanup deletes unused
* LockedObjects
*/
private final int _cleanupLimit = 100000;
protected int _cleanupCounter = 0;
/**
* keys: path value: LockedObject from that path
*/
protected Hashtable<String, LockedObject> _locks = new Hashtable<String, LockedObject>();
/**
* keys: id value: LockedObject from that id
*/
protected Hashtable<String, LockedObject> _locksByID = new Hashtable<String, LockedObject>();
/**
* keys: path value: Temporary LockedObject from that path
*/
protected Hashtable<String, LockedObject> _tempLocks = new Hashtable<String, LockedObject>();
/**
* keys: id value: Temporary LockedObject from that id
*/
protected Hashtable<String, LockedObject> _tempLocksByID = new Hashtable<String, LockedObject>();
// REMEMBER TO REMOVE UNUSED LOCKS FROM THE HASHTABLE AS WELL
protected LockedObject _root = null;
protected LockedObject _tempRoot = null;
private boolean _temporary = true;
public ResourceLocks() {
_root = new LockedObject(this, "/", true);
_tempRoot = new LockedObject(this, "/", false);
}
|
// Path: src/main/java/net/sf/webdav/ITransaction.java
// public interface ITransaction {
//
// Principal getPrincipal();
//
// }
//
// Path: src/main/java/net/sf/webdav/exceptions/LockFailedException.java
// public class LockFailedException extends WebdavException {
//
// public LockFailedException() {
// super();
// }
//
// public LockFailedException(String message) {
// super(message);
// }
//
// public LockFailedException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LockFailedException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/net/sf/webdav/locking/ResourceLocks.java
import java.util.Enumeration;
import java.util.Hashtable;
import net.sf.webdav.ITransaction;
import net.sf.webdav.exceptions.LockFailedException;
/*
* Copyright 2005-2006 webdav-servlet group.
*
* 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 net.sf.webdav.locking;
/**
* simple locking management for concurrent data access, NOT the webdav locking.
* ( could that be used instead? )
*
* IT IS ACTUALLY USED FOR DOLOCK
*
* @author re
*/
public class ResourceLocks implements IResourceLocks {
private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory
.getLogger(ResourceLocks.class);
/**
* after creating this much LockedObjects, a cleanup deletes unused
* LockedObjects
*/
private final int _cleanupLimit = 100000;
protected int _cleanupCounter = 0;
/**
* keys: path value: LockedObject from that path
*/
protected Hashtable<String, LockedObject> _locks = new Hashtable<String, LockedObject>();
/**
* keys: id value: LockedObject from that id
*/
protected Hashtable<String, LockedObject> _locksByID = new Hashtable<String, LockedObject>();
/**
* keys: path value: Temporary LockedObject from that path
*/
protected Hashtable<String, LockedObject> _tempLocks = new Hashtable<String, LockedObject>();
/**
* keys: id value: Temporary LockedObject from that id
*/
protected Hashtable<String, LockedObject> _tempLocksByID = new Hashtable<String, LockedObject>();
// REMEMBER TO REMOVE UNUSED LOCKS FROM THE HASHTABLE AS WELL
protected LockedObject _root = null;
protected LockedObject _tempRoot = null;
private boolean _temporary = true;
public ResourceLocks() {
_root = new LockedObject(this, "/", true);
_tempRoot = new LockedObject(this, "/", false);
}
|
public synchronized boolean lock(ITransaction transaction, String path,
|
ceefour/webdav-servlet
|
src/main/java/net/sf/webdav/locking/ResourceLocks.java
|
// Path: src/main/java/net/sf/webdav/ITransaction.java
// public interface ITransaction {
//
// Principal getPrincipal();
//
// }
//
// Path: src/main/java/net/sf/webdav/exceptions/LockFailedException.java
// public class LockFailedException extends WebdavException {
//
// public LockFailedException() {
// super();
// }
//
// public LockFailedException(String message) {
// super(message);
// }
//
// public LockFailedException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LockFailedException(Throwable cause) {
// super(cause);
// }
// }
|
import java.util.Enumeration;
import java.util.Hashtable;
import net.sf.webdav.ITransaction;
import net.sf.webdav.exceptions.LockFailedException;
|
/*
* Copyright 2005-2006 webdav-servlet group.
*
* 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 net.sf.webdav.locking;
/**
* simple locking management for concurrent data access, NOT the webdav locking.
* ( could that be used instead? )
*
* IT IS ACTUALLY USED FOR DOLOCK
*
* @author re
*/
public class ResourceLocks implements IResourceLocks {
private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory
.getLogger(ResourceLocks.class);
/**
* after creating this much LockedObjects, a cleanup deletes unused
* LockedObjects
*/
private final int _cleanupLimit = 100000;
protected int _cleanupCounter = 0;
/**
* keys: path value: LockedObject from that path
*/
protected Hashtable<String, LockedObject> _locks = new Hashtable<String, LockedObject>();
/**
* keys: id value: LockedObject from that id
*/
protected Hashtable<String, LockedObject> _locksByID = new Hashtable<String, LockedObject>();
/**
* keys: path value: Temporary LockedObject from that path
*/
protected Hashtable<String, LockedObject> _tempLocks = new Hashtable<String, LockedObject>();
/**
* keys: id value: Temporary LockedObject from that id
*/
protected Hashtable<String, LockedObject> _tempLocksByID = new Hashtable<String, LockedObject>();
// REMEMBER TO REMOVE UNUSED LOCKS FROM THE HASHTABLE AS WELL
protected LockedObject _root = null;
protected LockedObject _tempRoot = null;
private boolean _temporary = true;
public ResourceLocks() {
_root = new LockedObject(this, "/", true);
_tempRoot = new LockedObject(this, "/", false);
}
public synchronized boolean lock(ITransaction transaction, String path,
String owner, boolean exclusive, int depth, int timeout,
|
// Path: src/main/java/net/sf/webdav/ITransaction.java
// public interface ITransaction {
//
// Principal getPrincipal();
//
// }
//
// Path: src/main/java/net/sf/webdav/exceptions/LockFailedException.java
// public class LockFailedException extends WebdavException {
//
// public LockFailedException() {
// super();
// }
//
// public LockFailedException(String message) {
// super(message);
// }
//
// public LockFailedException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LockFailedException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/net/sf/webdav/locking/ResourceLocks.java
import java.util.Enumeration;
import java.util.Hashtable;
import net.sf.webdav.ITransaction;
import net.sf.webdav.exceptions.LockFailedException;
/*
* Copyright 2005-2006 webdav-servlet group.
*
* 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 net.sf.webdav.locking;
/**
* simple locking management for concurrent data access, NOT the webdav locking.
* ( could that be used instead? )
*
* IT IS ACTUALLY USED FOR DOLOCK
*
* @author re
*/
public class ResourceLocks implements IResourceLocks {
private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory
.getLogger(ResourceLocks.class);
/**
* after creating this much LockedObjects, a cleanup deletes unused
* LockedObjects
*/
private final int _cleanupLimit = 100000;
protected int _cleanupCounter = 0;
/**
* keys: path value: LockedObject from that path
*/
protected Hashtable<String, LockedObject> _locks = new Hashtable<String, LockedObject>();
/**
* keys: id value: LockedObject from that id
*/
protected Hashtable<String, LockedObject> _locksByID = new Hashtable<String, LockedObject>();
/**
* keys: path value: Temporary LockedObject from that path
*/
protected Hashtable<String, LockedObject> _tempLocks = new Hashtable<String, LockedObject>();
/**
* keys: id value: Temporary LockedObject from that id
*/
protected Hashtable<String, LockedObject> _tempLocksByID = new Hashtable<String, LockedObject>();
// REMEMBER TO REMOVE UNUSED LOCKS FROM THE HASHTABLE AS WELL
protected LockedObject _root = null;
protected LockedObject _tempRoot = null;
private boolean _temporary = true;
public ResourceLocks() {
_root = new LockedObject(this, "/", true);
_tempRoot = new LockedObject(this, "/", false);
}
public synchronized boolean lock(ITransaction transaction, String path,
String owner, boolean exclusive, int depth, int timeout,
|
boolean temporary) throws LockFailedException {
|
ceefour/webdav-servlet
|
src/main/java/net/sf/webdav/LocalFileSystemStore.java
|
// Path: src/main/java/net/sf/webdav/exceptions/WebdavException.java
// public class WebdavException extends RuntimeException {
//
// public WebdavException() {
// super();
// }
//
// public WebdavException(String message) {
// super(message);
// }
//
// public WebdavException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public WebdavException(Throwable cause) {
// super(cause);
// }
// }
|
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import net.sf.webdav.exceptions.WebdavException;
|
/*
*
* 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 net.sf.webdav;
/**
* Reference Implementation of WebdavStore
*
* @author joa
* @author re
*/
public class LocalFileSystemStore implements IWebdavStore {
private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory
.getLogger(LocalFileSystemStore.class);
private static int BUF_SIZE = 65536;
private File _root = null;
public LocalFileSystemStore(File root) {
_root = root;
}
public void destroy() {
;
}
|
// Path: src/main/java/net/sf/webdav/exceptions/WebdavException.java
// public class WebdavException extends RuntimeException {
//
// public WebdavException() {
// super();
// }
//
// public WebdavException(String message) {
// super(message);
// }
//
// public WebdavException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public WebdavException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/net/sf/webdav/LocalFileSystemStore.java
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import net.sf.webdav.exceptions.WebdavException;
/*
*
* 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 net.sf.webdav;
/**
* Reference Implementation of WebdavStore
*
* @author joa
* @author re
*/
public class LocalFileSystemStore implements IWebdavStore {
private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory
.getLogger(LocalFileSystemStore.class);
private static int BUF_SIZE = 65536;
private File _root = null;
public LocalFileSystemStore(File root) {
_root = root;
}
public void destroy() {
;
}
|
public ITransaction begin(Principal principal) throws WebdavException {
|
ceefour/webdav-servlet
|
src/main/java/net/sf/webdav/methods/DeterminableMethod.java
|
// Path: src/main/java/net/sf/webdav/StoredObject.java
// public class StoredObject {
//
// private boolean isFolder;
// private Date lastModified;
// private Date creationDate;
// private long contentLength;
// private String mimeType;
//
// private boolean isNullRessource;
//
// /**
// * Determines whether the StoredObject is a folder or a resource
// *
// * @return true if the StoredObject is a collection
// */
// public boolean isFolder() {
// return (isFolder);
// }
//
// /**
// * Determines whether the StoredObject is a folder or a resource
// *
// * @return true if the StoredObject is a resource
// */
// public boolean isResource() {
// return (!isFolder);
// }
//
// /**
// * Sets a new StoredObject as a collection or resource
// *
// * @param f
// * true - collection ; false - resource
// */
// public void setFolder(boolean f) {
// this.isFolder = f;
// }
//
// /**
// * Gets the date of the last modification
// *
// * @return last modification Date
// */
// public Date getLastModified() {
// return (lastModified);
// }
//
// /**
// * Sets the date of the last modification
// *
// * @param d
// * date of the last modification
// */
// public void setLastModified(Date d) {
// this.lastModified = d;
// }
//
// /**
// * Gets the date of the creation
// *
// * @return creation Date
// */
// public Date getCreationDate() {
// return (creationDate);
// }
//
// /**
// * Sets the date of the creation
// *
// * @param d
// * date of the creation
// */
// public void setCreationDate(Date c) {
// this.creationDate = c;
// }
//
// /**
// * Gets the length of the resource content
// *
// * @return length of the resource content
// */
// public long getResourceLength() {
// return (contentLength);
// }
//
// /**
// * Sets the length of the resource content
// *
// * @param l
// * the length of the resource content
// */
// public void setResourceLength(long l) {
// this.contentLength = l;
// }
//
// /**
// * Gets the state of the resource
// *
// * @return true if the resource is in lock-null state
// */
// public boolean isNullResource() {
// return isNullRessource;
// }
//
// /**
// * Sets a StoredObject as a lock-null resource
// *
// * @param f
// * true to set the resource as lock-null resource
// */
// public void setNullResource(boolean f) {
// this.isNullRessource = f;
// this.isFolder = false;
// this.creationDate = null;
// this.lastModified = null;
// // this.content = null;
// this.contentLength = 0;
// this.mimeType= null;
// }
//
// /**
// * Retrieve the myme type from the store object.
// * Can also return NULL if the store does not handle
// * mime type stuff.
// * In that case the mime type is determined by the servletcontext
// *
// * @return the mimeType
// */
// public String getMimeType() {
// return mimeType;
// }
//
// /**
// * Set the mime type of this object
// *
// * @param mimeType the mimeType to set
// */
// public void setMimeType(String mimeType) {
// this.mimeType = mimeType;
// }
//
// }
|
import net.sf.webdav.StoredObject;
|
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* 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 net.sf.webdav.methods;
public abstract class DeterminableMethod extends AbstractMethod {
private static final String NULL_RESOURCE_METHODS_ALLOWED = "OPTIONS, MKCOL, PUT, PROPFIND, LOCK, UNLOCK";
private static final String RESOURCE_METHODS_ALLOWED = "OPTIONS, GET, HEAD, POST, DELETE, TRACE"
+ ", PROPPATCH, COPY, MOVE, LOCK, UNLOCK, PROPFIND";
private static final String FOLDER_METHOD_ALLOWED = ", PUT";
private static final String LESS_ALLOWED_METHODS = "OPTIONS, MKCOL, PUT";
/**
* Determines the methods normally allowed for the resource.
*
* @param so
* StoredObject representing the resource
* @return all allowed methods, separated by commas
*/
|
// Path: src/main/java/net/sf/webdav/StoredObject.java
// public class StoredObject {
//
// private boolean isFolder;
// private Date lastModified;
// private Date creationDate;
// private long contentLength;
// private String mimeType;
//
// private boolean isNullRessource;
//
// /**
// * Determines whether the StoredObject is a folder or a resource
// *
// * @return true if the StoredObject is a collection
// */
// public boolean isFolder() {
// return (isFolder);
// }
//
// /**
// * Determines whether the StoredObject is a folder or a resource
// *
// * @return true if the StoredObject is a resource
// */
// public boolean isResource() {
// return (!isFolder);
// }
//
// /**
// * Sets a new StoredObject as a collection or resource
// *
// * @param f
// * true - collection ; false - resource
// */
// public void setFolder(boolean f) {
// this.isFolder = f;
// }
//
// /**
// * Gets the date of the last modification
// *
// * @return last modification Date
// */
// public Date getLastModified() {
// return (lastModified);
// }
//
// /**
// * Sets the date of the last modification
// *
// * @param d
// * date of the last modification
// */
// public void setLastModified(Date d) {
// this.lastModified = d;
// }
//
// /**
// * Gets the date of the creation
// *
// * @return creation Date
// */
// public Date getCreationDate() {
// return (creationDate);
// }
//
// /**
// * Sets the date of the creation
// *
// * @param d
// * date of the creation
// */
// public void setCreationDate(Date c) {
// this.creationDate = c;
// }
//
// /**
// * Gets the length of the resource content
// *
// * @return length of the resource content
// */
// public long getResourceLength() {
// return (contentLength);
// }
//
// /**
// * Sets the length of the resource content
// *
// * @param l
// * the length of the resource content
// */
// public void setResourceLength(long l) {
// this.contentLength = l;
// }
//
// /**
// * Gets the state of the resource
// *
// * @return true if the resource is in lock-null state
// */
// public boolean isNullResource() {
// return isNullRessource;
// }
//
// /**
// * Sets a StoredObject as a lock-null resource
// *
// * @param f
// * true to set the resource as lock-null resource
// */
// public void setNullResource(boolean f) {
// this.isNullRessource = f;
// this.isFolder = false;
// this.creationDate = null;
// this.lastModified = null;
// // this.content = null;
// this.contentLength = 0;
// this.mimeType= null;
// }
//
// /**
// * Retrieve the myme type from the store object.
// * Can also return NULL if the store does not handle
// * mime type stuff.
// * In that case the mime type is determined by the servletcontext
// *
// * @return the mimeType
// */
// public String getMimeType() {
// return mimeType;
// }
//
// /**
// * Set the mime type of this object
// *
// * @param mimeType the mimeType to set
// */
// public void setMimeType(String mimeType) {
// this.mimeType = mimeType;
// }
//
// }
// Path: src/main/java/net/sf/webdav/methods/DeterminableMethod.java
import net.sf.webdav.StoredObject;
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* 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 net.sf.webdav.methods;
public abstract class DeterminableMethod extends AbstractMethod {
private static final String NULL_RESOURCE_METHODS_ALLOWED = "OPTIONS, MKCOL, PUT, PROPFIND, LOCK, UNLOCK";
private static final String RESOURCE_METHODS_ALLOWED = "OPTIONS, GET, HEAD, POST, DELETE, TRACE"
+ ", PROPPATCH, COPY, MOVE, LOCK, UNLOCK, PROPFIND";
private static final String FOLDER_METHOD_ALLOWED = ", PUT";
private static final String LESS_ALLOWED_METHODS = "OPTIONS, MKCOL, PUT";
/**
* Determines the methods normally allowed for the resource.
*
* @param so
* StoredObject representing the resource
* @return all allowed methods, separated by commas
*/
|
protected static String determineMethodsAllowed(StoredObject so) {
|
ceefour/webdav-servlet
|
src/main/java/net/sf/webdav/locking/IResourceLocks.java
|
// Path: src/main/java/net/sf/webdav/ITransaction.java
// public interface ITransaction {
//
// Principal getPrincipal();
//
// }
//
// Path: src/main/java/net/sf/webdav/exceptions/LockFailedException.java
// public class LockFailedException extends WebdavException {
//
// public LockFailedException() {
// super();
// }
//
// public LockFailedException(String message) {
// super(message);
// }
//
// public LockFailedException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LockFailedException(Throwable cause) {
// super(cause);
// }
// }
|
import net.sf.webdav.ITransaction;
import net.sf.webdav.exceptions.LockFailedException;
|
package net.sf.webdav.locking;
public interface IResourceLocks {
/**
* Tries to lock the resource at "path".
*
* @param transaction
* @param path
* what resource to lock
* @param owner
* the owner of the lock
* @param exclusive
* if the lock should be exclusive (or shared)
* @param depth
* depth
* @param timeout
* Lock Duration in seconds.
* @return true if the resource at path was successfully locked, false if an
* existing lock prevented this
* @throws LockFailedException
*/
boolean lock(ITransaction transaction, String path, String owner,
boolean exclusive, int depth, int timeout, boolean temporary)
|
// Path: src/main/java/net/sf/webdav/ITransaction.java
// public interface ITransaction {
//
// Principal getPrincipal();
//
// }
//
// Path: src/main/java/net/sf/webdav/exceptions/LockFailedException.java
// public class LockFailedException extends WebdavException {
//
// public LockFailedException() {
// super();
// }
//
// public LockFailedException(String message) {
// super(message);
// }
//
// public LockFailedException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LockFailedException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/net/sf/webdav/locking/IResourceLocks.java
import net.sf.webdav.ITransaction;
import net.sf.webdav.exceptions.LockFailedException;
package net.sf.webdav.locking;
public interface IResourceLocks {
/**
* Tries to lock the resource at "path".
*
* @param transaction
* @param path
* what resource to lock
* @param owner
* the owner of the lock
* @param exclusive
* if the lock should be exclusive (or shared)
* @param depth
* depth
* @param timeout
* Lock Duration in seconds.
* @return true if the resource at path was successfully locked, false if an
* existing lock prevented this
* @throws LockFailedException
*/
boolean lock(ITransaction transaction, String path, String owner,
boolean exclusive, int depth, int timeout, boolean temporary)
|
throws LockFailedException;
|
ceefour/webdav-servlet
|
src/main/java/net/sf/webdav/WebdavServlet.java
|
// Path: src/main/java/net/sf/webdav/exceptions/WebdavException.java
// public class WebdavException extends RuntimeException {
//
// public WebdavException() {
// super();
// }
//
// public WebdavException(String message) {
// super(message);
// }
//
// public WebdavException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public WebdavException(Throwable cause) {
// super(cause);
// }
// }
|
import java.io.File;
import java.lang.reflect.Constructor;
import javax.servlet.ServletException;
import net.sf.webdav.exceptions.WebdavException;
|
super.init(webdavStore, dftIndexFile, insteadOf404,
noContentLengthHeader, lazyFolderCreationOnPut);
}
private int getIntInitParameter(String key) {
return getInitParameter(key) == null ? -1 : Integer
.parseInt(getInitParameter(key));
}
protected IWebdavStore constructStore(String clazzName, File root) {
IWebdavStore webdavStore;
try {
Class<?> clazz = WebdavServlet.class.getClassLoader().loadClass(
clazzName);
Constructor<?> ctor = clazz
.getConstructor(new Class[] { File.class });
webdavStore = (IWebdavStore) ctor
.newInstance(new Object[] { root });
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("some problem making store component", e);
}
return webdavStore;
}
private File getFileRoot() {
String rootPath = getInitParameter(ROOTPATH_PARAMETER);
if (rootPath == null) {
|
// Path: src/main/java/net/sf/webdav/exceptions/WebdavException.java
// public class WebdavException extends RuntimeException {
//
// public WebdavException() {
// super();
// }
//
// public WebdavException(String message) {
// super(message);
// }
//
// public WebdavException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public WebdavException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/net/sf/webdav/WebdavServlet.java
import java.io.File;
import java.lang.reflect.Constructor;
import javax.servlet.ServletException;
import net.sf.webdav.exceptions.WebdavException;
super.init(webdavStore, dftIndexFile, insteadOf404,
noContentLengthHeader, lazyFolderCreationOnPut);
}
private int getIntInitParameter(String key) {
return getInitParameter(key) == null ? -1 : Integer
.parseInt(getInitParameter(key));
}
protected IWebdavStore constructStore(String clazzName, File root) {
IWebdavStore webdavStore;
try {
Class<?> clazz = WebdavServlet.class.getClassLoader().loadClass(
clazzName);
Constructor<?> ctor = clazz
.getConstructor(new Class[] { File.class });
webdavStore = (IWebdavStore) ctor
.newInstance(new Object[] { root });
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("some problem making store component", e);
}
return webdavStore;
}
private File getFileRoot() {
String rootPath = getInitParameter(ROOTPATH_PARAMETER);
if (rootPath == null) {
|
throw new WebdavException("missing parameter: "
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/SpinnerPresserTest.java
|
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
|
import static org.mockito.Mockito.*;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import android.app.Instrumentation;
import android.view.KeyEvent;
import android.widget.Spinner;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
|
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class SpinnerPresserTest {
|
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
// Path: units/src/com/leandog/brazenhead/SpinnerPresserTest.java
import static org.mockito.Mockito.*;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import android.app.Instrumentation;
import android.view.KeyEvent;
import android.widget.Spinner;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class SpinnerPresserTest {
|
@RunWith(BrazenheadTestRunner.class)
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/SpinnerPresserTest.java
|
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
|
import static org.mockito.Mockito.*;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import android.app.Instrumentation;
import android.view.KeyEvent;
import android.widget.Spinner;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
|
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class SpinnerPresserTest {
@RunWith(BrazenheadTestRunner.class)
public static class PressingSpinnerItemsByView {
@Mock Solo solo;
@Mock Instrumentation instrumentation;
|
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
// Path: units/src/com/leandog/brazenhead/SpinnerPresserTest.java
import static org.mockito.Mockito.*;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import android.app.Instrumentation;
import android.view.KeyEvent;
import android.widget.Spinner;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class SpinnerPresserTest {
@RunWith(BrazenheadTestRunner.class)
public static class PressingSpinnerItemsByView {
@Mock Solo solo;
@Mock Instrumentation instrumentation;
|
@Mock BrazenheadSleeper sleeper;
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/ListItemFinder.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
|
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
|
package com.leandog.brazenhead;
public class ListItemFinder {
private final Solo solo;
private final Instrumentation instrumentation;
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
// Path: driver/src/com/leandog/brazenhead/ListItemFinder.java
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
package com.leandog.brazenhead;
public class ListItemFinder {
private final Solo solo;
private final Instrumentation instrumentation;
|
private final BrazenheadSleeper sleeper;
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/ListItemFinder.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
|
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
|
waitForText(itemText, solo);
final TextView theFoundText = solo.getText(itemText);
View foundListItem = theFoundText;
View theParent = theParentOf(theFoundText);
while (atTheRootViewFor(theParent)) {
foundListItem = theParent;
theParent = theParentOf(theParent);
}
assertWasAListItem(foundListItem, theParent);
return foundListItem;
}
private View theParentOf(final View view) {
return (View) view.getParent();
}
private void waitForText(final String itemText, final Solo solo) throws Exception {
if (!solo.waitForText(itemText)) {
throw new Exception(String.format("A View with text \"%s\" was not found", itemText));
}
}
private boolean atTheRootViewFor(View theParent) {
return theParent != null && !(theParent instanceof AbsListView);
}
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
// Path: driver/src/com/leandog/brazenhead/ListItemFinder.java
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
waitForText(itemText, solo);
final TextView theFoundText = solo.getText(itemText);
View foundListItem = theFoundText;
View theParent = theParentOf(theFoundText);
while (atTheRootViewFor(theParent)) {
foundListItem = theParent;
theParent = theParentOf(theParent);
}
assertWasAListItem(foundListItem, theParent);
return foundListItem;
}
private View theParentOf(final View view) {
return (View) view.getParent();
}
private void waitForText(final String itemText, final Solo solo) throws Exception {
if (!solo.waitForText(itemText)) {
throw new Exception(String.format("A View with text \"%s\" was not found", itemText));
}
}
private boolean atTheRootViewFor(View theParent) {
return theParent != null && !(theParent instanceof AbsListView);
}
|
private void assertWasAListItem(View foundListItem, View theParent) throws IsNotAListViewItem {
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/commands/CommandTest.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.experimental.theories.*;
import org.junit.runner.RunWith;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.commands.Command.Target;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
|
package com.leandog.brazenhead.commands;
@RunWith(Theories.class)
public class CommandTest {
@Test
public void itSetsTheAppropriateDefaultsForTheCommand() {
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
// Path: units/src/com/leandog/brazenhead/commands/CommandTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.experimental.theories.*;
import org.junit.runner.RunWith;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.commands.Command.Target;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
package com.leandog.brazenhead.commands;
@RunWith(Theories.class)
public class CommandTest {
@Test
public void itSetsTheAppropriateDefaultsForTheCommand() {
|
final Command theCommand = new Command();
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/commands/CommandTest.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.experimental.theories.*;
import org.junit.runner.RunWith;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.commands.Command.Target;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
|
assertThat(firstCommand.hashCode(), is(sameCommand.hashCode()));
}
@Test
public void itConsidersTheArgumentsInTheHash() {
final Command firstCommand = new Command("command", 1, "hello");
final Command sameCommand = new Command("command", 1, "hello");
assertThat(firstCommand.hashCode(), is(sameCommand.hashCode()));
}
@Test
public void itConsidersVoidMethodsOfTheSameNameAsEqual() {
assertThat(new Command("command"), is(new Command("command")));
}
@Test
public void itConsidersMethodsWithDifferentNamesNotEqual() {
assertThat(new Command("command"), is(not(new Command("the other command"))));
}
@Test
public void aNullCommandCannotEqualAValidCommand() {
assertThat(new Command("command").equals(null), is(false));
}
@Test
public void itConsidersTheArgumentsWhenDeterminingEquality() {
assertThat(new Command("command", 1, "hello"), is(new Command("command", 1, "hello")));
}
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
// Path: units/src/com/leandog/brazenhead/commands/CommandTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.experimental.theories.*;
import org.junit.runner.RunWith;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.commands.Command.Target;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
assertThat(firstCommand.hashCode(), is(sameCommand.hashCode()));
}
@Test
public void itConsidersTheArgumentsInTheHash() {
final Command firstCommand = new Command("command", 1, "hello");
final Command sameCommand = new Command("command", 1, "hello");
assertThat(firstCommand.hashCode(), is(sameCommand.hashCode()));
}
@Test
public void itConsidersVoidMethodsOfTheSameNameAsEqual() {
assertThat(new Command("command"), is(new Command("command")));
}
@Test
public void itConsidersMethodsWithDifferentNamesNotEqual() {
assertThat(new Command("command"), is(not(new Command("the other command"))));
}
@Test
public void aNullCommandCannotEqualAValidCommand() {
assertThat(new Command("command").equals(null), is(false));
}
@Test
public void itConsidersTheArgumentsWhenDeterminingEquality() {
assertThat(new Command("command", 1, "hello"), is(new Command("command", 1, "hello")));
}
|
@Test(expected = IllegalVariableArgumentException.class)
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/commands/CommandTest.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.experimental.theories.*;
import org.junit.runner.RunWith;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.commands.Command.Target;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
|
public void itConsidersMethodsWithDifferentNamesNotEqual() {
assertThat(new Command("command"), is(not(new Command("the other command"))));
}
@Test
public void aNullCommandCannotEqualAValidCommand() {
assertThat(new Command("command").equals(null), is(false));
}
@Test
public void itConsidersTheArgumentsWhenDeterminingEquality() {
assertThat(new Command("command", 1, "hello"), is(new Command("command", 1, "hello")));
}
@Test(expected = IllegalVariableArgumentException.class)
public void variableNamesMustConform() {
new Command("anything").setVariable("bad");
}
@DataPoints
public static Command[] defaultTargets() {
return new Command[] {
new Command(),
new Command("name"),
new Command("name", 1)
};
}
@Theory
public void itDefaultsTheTargetToLastResultOrRobotium(final Command command) {
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
// Path: units/src/com/leandog/brazenhead/commands/CommandTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.experimental.theories.*;
import org.junit.runner.RunWith;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.commands.Command.Target;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
public void itConsidersMethodsWithDifferentNamesNotEqual() {
assertThat(new Command("command"), is(not(new Command("the other command"))));
}
@Test
public void aNullCommandCannotEqualAValidCommand() {
assertThat(new Command("command").equals(null), is(false));
}
@Test
public void itConsidersTheArgumentsWhenDeterminingEquality() {
assertThat(new Command("command", 1, "hello"), is(new Command("command", 1, "hello")));
}
@Test(expected = IllegalVariableArgumentException.class)
public void variableNamesMustConform() {
new Command("anything").setVariable("bad");
}
@DataPoints
public static Command[] defaultTargets() {
return new Command[] {
new Command(),
new Command("name"),
new Command("name", 1)
};
}
@Theory
public void itDefaultsTheTargetToLastResultOrRobotium(final Command command) {
|
assertThat(command.getTarget(), is(Target.LastResultOrRobotium));
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/TheTest.java
|
// Path: driver/src/com/leandog/brazenhead/server/JettyServer.java
// public class JettyServer {
//
// final private Server server;
//
// public JettyServer() {
// this.server = new Server();
// }
//
// public void setHandler(AbstractHandler handler) {
// server.setHandler(handler);
// }
//
// public void addConnector(Connector createConnector) {
// server.addConnector(createConnector);
// }
//
// public void start() throws Exception {
// server.start();
// }
//
// public void join() throws InterruptedException {
// server.join();
// }
//
// public void stop() throws Exception {
// server.stop();
// }
//
// }
|
import android.test.ActivityInstrumentationTestCase2;
import com.leandog.brazenhead.server.JettyServer;
import com.robotium.solo.Solo;
|
package com.leandog.brazenhead;
@SuppressWarnings("rawtypes")
public class TheTest extends ActivityInstrumentationTestCase2 {
BrazenheadServer brazenheadServer;
@SuppressWarnings("unchecked")
public TheTest() throws ClassNotFoundException {
super(TestRunInformation.getPackageName(), Class.forName(TestRunInformation.getFullLauncherName()));
}
@Override
protected void setUp() throws Exception {
TestRunInformation.setSolo(new Solo(getInstrumentation(), getActivity()));
TestRunInformation.setBrazenhead(new Brazenhead(getInstrumentation(), TestRunInformation.getSolo()));
|
// Path: driver/src/com/leandog/brazenhead/server/JettyServer.java
// public class JettyServer {
//
// final private Server server;
//
// public JettyServer() {
// this.server = new Server();
// }
//
// public void setHandler(AbstractHandler handler) {
// server.setHandler(handler);
// }
//
// public void addConnector(Connector createConnector) {
// server.addConnector(createConnector);
// }
//
// public void start() throws Exception {
// server.start();
// }
//
// public void join() throws InterruptedException {
// server.join();
// }
//
// public void stop() throws Exception {
// server.stop();
// }
//
// }
// Path: driver/src/com/leandog/brazenhead/TheTest.java
import android.test.ActivityInstrumentationTestCase2;
import com.leandog.brazenhead.server.JettyServer;
import com.robotium.solo.Solo;
package com.leandog.brazenhead;
@SuppressWarnings("rawtypes")
public class TheTest extends ActivityInstrumentationTestCase2 {
BrazenheadServer brazenheadServer;
@SuppressWarnings("unchecked")
public TheTest() throws ClassNotFoundException {
super(TestRunInformation.getPackageName(), Class.forName(TestRunInformation.getFullLauncherName()));
}
@Override
protected void setUp() throws Exception {
TestRunInformation.setSolo(new Solo(getInstrumentation(), getActivity()));
TestRunInformation.setBrazenhead(new Brazenhead(getInstrumentation(), TestRunInformation.getSolo()));
|
brazenheadServer = new BrazenheadServer(new JettyServer());
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/BrazenheadServer.java
|
// Path: driver/src/com/leandog/brazenhead/commands/CommandRunner.java
// public class CommandRunner {
//
// private Object theLastResult;
//
// Map<String, Object> variables = new HashMap<String, Object>();
//
// public void execute(final Command... commands) throws Exception {
// clearLastRun();
//
// for (final Command command : commands) {
// theLastResult = findMethod(command).invoke(theTargetFor(command), theArguments(command));
//
// if (command.hasVariable()) {
// storeVariable(command);
// }
// }
// }
//
// public Object theLastResult() {
// return theLastResult;
// }
//
// private Method findMethod(final Command command) throws CommandNotFoundException {
// return new MethodFinder().find(command.getName()).on(theTargetFor(command).getClass()).with(argumentTypesFor(command));
// }
//
// private void clearLastRun() {
// theLastResult = null;
// variables.clear();
// }
//
// private Object theTargetFor(final Command command) {
// switch (command.getTarget()) {
// case Brazenhead:
// return TestRunInformation.getBrazenhead();
// case Robotium:
// return TestRunInformation.getSolo();
// default:
// return (theLastResult == null) ? TestRunInformation.getSolo() : theLastResult;
// }
//
// }
//
// private static Map<Class<?>, Class<?>> primitiveMap = new HashMap<Class<?>, Class<?>>();
// static {
// primitiveMap.put(Integer.class, int.class);
// primitiveMap.put(Boolean.class, boolean.class);
// primitiveMap.put(Float.class, float.class);
// }
//
// private Class<? extends Object> typeFor(final Object argument) {
// Class<?> argumentType = argument.getClass();
// Class<?> primitiveType = primitiveMap.get(argumentType);
// return (primitiveType == null) ? argumentType : primitiveType;
// }
//
// private Class<?>[] argumentTypesFor(final Command command) {
// Class<?>[] types = new Class<?>[theArguments(command).length];
//
// int index = 0;
// for (final Object argument : theArguments(command)) {
// types[index++] = typeFor(argument);
// }
//
// return types;
// }
//
// private Object[] theArguments(final Command command) {
// List<Object> arguments = Arrays.asList(command.getArguments());
// substituteVariables(arguments);
// return arguments.toArray();
// }
//
// private void substituteVariables(List<Object> arguments) {
// for (final Entry<String, Object> variable : variables.entrySet()) {
// Collections.replaceAll(arguments, variable.getKey(), variable.getValue());
// }
// }
//
// private void storeVariable(final Command command) {
// variables.put(command.getVariable(), theLastResult);
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/server/JettyServer.java
// public class JettyServer {
//
// final private Server server;
//
// public JettyServer() {
// this.server = new Server();
// }
//
// public void setHandler(AbstractHandler handler) {
// server.setHandler(handler);
// }
//
// public void addConnector(Connector createConnector) {
// server.addConnector(createConnector);
// }
//
// public void start() throws Exception {
// server.start();
// }
//
// public void join() throws InterruptedException {
// server.join();
// }
//
// public void stop() throws Exception {
// server.stop();
// }
//
// }
|
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.bio.SocketConnector;
import android.util.Log;
import com.leandog.brazenhead.commands.CommandRunner;
import com.leandog.brazenhead.server.JettyServer;
|
package com.leandog.brazenhead;
public class BrazenheadServer {
JettyServer server;
public BrazenheadServer(final JettyServer server) {
this.server = server;
}
public void start() throws Exception {
|
// Path: driver/src/com/leandog/brazenhead/commands/CommandRunner.java
// public class CommandRunner {
//
// private Object theLastResult;
//
// Map<String, Object> variables = new HashMap<String, Object>();
//
// public void execute(final Command... commands) throws Exception {
// clearLastRun();
//
// for (final Command command : commands) {
// theLastResult = findMethod(command).invoke(theTargetFor(command), theArguments(command));
//
// if (command.hasVariable()) {
// storeVariable(command);
// }
// }
// }
//
// public Object theLastResult() {
// return theLastResult;
// }
//
// private Method findMethod(final Command command) throws CommandNotFoundException {
// return new MethodFinder().find(command.getName()).on(theTargetFor(command).getClass()).with(argumentTypesFor(command));
// }
//
// private void clearLastRun() {
// theLastResult = null;
// variables.clear();
// }
//
// private Object theTargetFor(final Command command) {
// switch (command.getTarget()) {
// case Brazenhead:
// return TestRunInformation.getBrazenhead();
// case Robotium:
// return TestRunInformation.getSolo();
// default:
// return (theLastResult == null) ? TestRunInformation.getSolo() : theLastResult;
// }
//
// }
//
// private static Map<Class<?>, Class<?>> primitiveMap = new HashMap<Class<?>, Class<?>>();
// static {
// primitiveMap.put(Integer.class, int.class);
// primitiveMap.put(Boolean.class, boolean.class);
// primitiveMap.put(Float.class, float.class);
// }
//
// private Class<? extends Object> typeFor(final Object argument) {
// Class<?> argumentType = argument.getClass();
// Class<?> primitiveType = primitiveMap.get(argumentType);
// return (primitiveType == null) ? argumentType : primitiveType;
// }
//
// private Class<?>[] argumentTypesFor(final Command command) {
// Class<?>[] types = new Class<?>[theArguments(command).length];
//
// int index = 0;
// for (final Object argument : theArguments(command)) {
// types[index++] = typeFor(argument);
// }
//
// return types;
// }
//
// private Object[] theArguments(final Command command) {
// List<Object> arguments = Arrays.asList(command.getArguments());
// substituteVariables(arguments);
// return arguments.toArray();
// }
//
// private void substituteVariables(List<Object> arguments) {
// for (final Entry<String, Object> variable : variables.entrySet()) {
// Collections.replaceAll(arguments, variable.getKey(), variable.getValue());
// }
// }
//
// private void storeVariable(final Command command) {
// variables.put(command.getVariable(), theLastResult);
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/server/JettyServer.java
// public class JettyServer {
//
// final private Server server;
//
// public JettyServer() {
// this.server = new Server();
// }
//
// public void setHandler(AbstractHandler handler) {
// server.setHandler(handler);
// }
//
// public void addConnector(Connector createConnector) {
// server.addConnector(createConnector);
// }
//
// public void start() throws Exception {
// server.start();
// }
//
// public void join() throws InterruptedException {
// server.join();
// }
//
// public void stop() throws Exception {
// server.stop();
// }
//
// }
// Path: driver/src/com/leandog/brazenhead/BrazenheadServer.java
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.bio.SocketConnector;
import android.util.Log;
import com.leandog.brazenhead.commands.CommandRunner;
import com.leandog.brazenhead.server.JettyServer;
package com.leandog.brazenhead;
public class BrazenheadServer {
JettyServer server;
public BrazenheadServer(final JettyServer server) {
this.server = server;
}
public void start() throws Exception {
|
server.setHandler(new BrazenheadRequestHandler(this, new CommandRunner()));
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/commands/Command.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/util/Objects.java
// public class Objects {
//
// public static boolean equal(Object a, Object b) {
// return a == b || (a != null && a.equals(b));
// }
//
// public static int hashCode(Object... objects) {
// return Arrays.hashCode(objects);
// }
//
// }
|
import java.util.Arrays;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
import com.leandog.brazenhead.util.Objects;
|
this();
this.name = name;
this.arguments = arguments;
}
public Command(final String name, final Target target, final Object... arguments) {
this();
this.name = name;
this.arguments = arguments;
setTarget(target);
}
public String getName() {
return name;
}
public Object[] getArguments() {
return arguments;
}
public Target getTarget() {
return target;
}
public String variableName() {
return variable;
}
public void setVariable(final String variable) {
if( null != variable && !variable.matches("@@.*@@")) {
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/util/Objects.java
// public class Objects {
//
// public static boolean equal(Object a, Object b) {
// return a == b || (a != null && a.equals(b));
// }
//
// public static int hashCode(Object... objects) {
// return Arrays.hashCode(objects);
// }
//
// }
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
import java.util.Arrays;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
import com.leandog.brazenhead.util.Objects;
this();
this.name = name;
this.arguments = arguments;
}
public Command(final String name, final Target target, final Object... arguments) {
this();
this.name = name;
this.arguments = arguments;
setTarget(target);
}
public String getName() {
return name;
}
public Object[] getArguments() {
return arguments;
}
public Target getTarget() {
return target;
}
public String variableName() {
return variable;
}
public void setVariable(final String variable) {
if( null != variable && !variable.matches("@@.*@@")) {
|
throw new IllegalVariableArgumentException();
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/commands/Command.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/util/Objects.java
// public class Objects {
//
// public static boolean equal(Object a, Object b) {
// return a == b || (a != null && a.equals(b));
// }
//
// public static int hashCode(Object... objects) {
// return Arrays.hashCode(objects);
// }
//
// }
|
import java.util.Arrays;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
import com.leandog.brazenhead.util.Objects;
|
}
this.variable = variable;
}
public void setTarget(final Target target) {
if (target != null) {
this.target = target;
}
}
public boolean hasVariable() {
return variable != null;
}
public String getVariable() {
return variable;
}
@Override
public int hashCode() {
return name.hashCode() + Arrays.hashCode(arguments);
}
@Override
public boolean equals(Object other) {
if (null == other || !(other instanceof Command)) {
return false;
}
final Command otherCommand = (Command) other;
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IllegalVariableArgumentException.java
// public class IllegalVariableArgumentException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public IllegalVariableArgumentException() {
// super("Variable names must be in the form of '@@some_name@@'.");
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/util/Objects.java
// public class Objects {
//
// public static boolean equal(Object a, Object b) {
// return a == b || (a != null && a.equals(b));
// }
//
// public static int hashCode(Object... objects) {
// return Arrays.hashCode(objects);
// }
//
// }
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
import java.util.Arrays;
import com.leandog.brazenhead.exceptions.IllegalVariableArgumentException;
import com.leandog.brazenhead.util.Objects;
}
this.variable = variable;
}
public void setTarget(final Target target) {
if (target != null) {
this.target = target;
}
}
public boolean hasVariable() {
return variable != null;
}
public String getVariable() {
return variable;
}
@Override
public int hashCode() {
return name.hashCode() + Arrays.hashCode(arguments);
}
@Override
public boolean equals(Object other) {
if (null == other || !(other instanceof Command)) {
return false;
}
final Command otherCommand = (Command) other;
|
return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/json/CommandDeserializerTest.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
|
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.lang.reflect.Field;
import java.util.*;
import org.junit.*;
import com.google.brazenhead.gson.*;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.commands.Command.Target;
|
}
@Test
public void itCanGetABooleanArgument() {
Command actualCommand = deserialize("{arguments: [true]}");
assertThat(actualCommand.getArguments(), is(new Object[] { true }));
}
@Test
public void itCanGetAFloatArgument() {
Command actualCommand = deserialize("{arguments: [3.0]}");
assertThat(actualCommand.getArguments(), is(new Object[] { 3.0f }));
}
@Test
public void itCanGetADoubleArgument() {
Double maxDouble = Double.MAX_VALUE;
Command actualCommand = deserialize("{arguments: [" + maxDouble.toString() + "]}");
assertThat(actualCommand.getArguments(), is(new Object[] { maxDouble }));
}
@Test
public void itCanGetAStringArgument() {
Command actualCommand = deserialize("{arguments: [\"some string\"]}");
assertThat(actualCommand.getArguments(), is(new Object[] { "some string" }));
}
@Test
public void itCanParseOutTheDesiredTarget() {
Command actualCommand = deserialize("{target: 'Robotium'}");
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
// Path: units/src/com/leandog/brazenhead/json/CommandDeserializerTest.java
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.lang.reflect.Field;
import java.util.*;
import org.junit.*;
import com.google.brazenhead.gson.*;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.commands.Command.Target;
}
@Test
public void itCanGetABooleanArgument() {
Command actualCommand = deserialize("{arguments: [true]}");
assertThat(actualCommand.getArguments(), is(new Object[] { true }));
}
@Test
public void itCanGetAFloatArgument() {
Command actualCommand = deserialize("{arguments: [3.0]}");
assertThat(actualCommand.getArguments(), is(new Object[] { 3.0f }));
}
@Test
public void itCanGetADoubleArgument() {
Double maxDouble = Double.MAX_VALUE;
Command actualCommand = deserialize("{arguments: [" + maxDouble.toString() + "]}");
assertThat(actualCommand.getArguments(), is(new Object[] { maxDouble }));
}
@Test
public void itCanGetAStringArgument() {
Command actualCommand = deserialize("{arguments: [\"some string\"]}");
assertThat(actualCommand.getArguments(), is(new Object[] { "some string" }));
}
@Test
public void itCanParseOutTheDesiredTarget() {
Command actualCommand = deserialize("{target: 'Robotium'}");
|
assertThat(actualCommand.getTarget(), is(Target.Robotium));
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/BrazenheadServerTest.java
|
// Path: driver/src/com/leandog/brazenhead/server/JettyServer.java
// public class JettyServer {
//
// final private Server server;
//
// public JettyServer() {
// this.server = new Server();
// }
//
// public void setHandler(AbstractHandler handler) {
// server.setHandler(handler);
// }
//
// public void addConnector(Connector createConnector) {
// server.addConnector(createConnector);
// }
//
// public void start() throws Exception {
// server.start();
// }
//
// public void join() throws InterruptedException {
// server.join();
// }
//
// public void stop() throws Exception {
// server.stop();
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
|
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.verify;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.bio.SocketConnector;
import com.leandog.brazenhead.server.JettyServer;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
|
package com.leandog.brazenhead;
@RunWith(BrazenheadTestRunner.class)
public class BrazenheadServerTest {
|
// Path: driver/src/com/leandog/brazenhead/server/JettyServer.java
// public class JettyServer {
//
// final private Server server;
//
// public JettyServer() {
// this.server = new Server();
// }
//
// public void setHandler(AbstractHandler handler) {
// server.setHandler(handler);
// }
//
// public void addConnector(Connector createConnector) {
// server.addConnector(createConnector);
// }
//
// public void start() throws Exception {
// server.start();
// }
//
// public void join() throws InterruptedException {
// server.join();
// }
//
// public void stop() throws Exception {
// server.stop();
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
// Path: units/src/com/leandog/brazenhead/BrazenheadServerTest.java
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.verify;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.bio.SocketConnector;
import com.leandog.brazenhead.server.JettyServer;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
package com.leandog.brazenhead;
@RunWith(BrazenheadTestRunner.class)
public class BrazenheadServerTest {
|
@Mock JettyServer server;
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/commands/MethodFinder.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
|
import java.lang.reflect.Method;
import java.util.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
|
package com.leandog.brazenhead.commands;
public class MethodFinder {
private String methodName;
private Class<?> targetClass;
public MethodFinder find(final String methodName) {
this.methodName = methodName;
return this;
}
public MethodFinder on(final Class<?> targetClazz) {
this.targetClass = targetClazz;
return this;
}
|
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
// Path: driver/src/com/leandog/brazenhead/commands/MethodFinder.java
import java.lang.reflect.Method;
import java.util.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
package com.leandog.brazenhead.commands;
public class MethodFinder {
private String methodName;
private Class<?> targetClass;
public MethodFinder find(final String methodName) {
this.methodName = methodName;
return this;
}
public MethodFinder on(final Class<?> targetClazz) {
this.targetClass = targetClazz;
return this;
}
|
public Method with(final Class<?>[] argumentTypes) throws CommandNotFoundException {
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/json/CommandDeserializer.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
|
import java.lang.reflect.Type;
import com.google.brazenhead.gson.*;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.commands.Command.Target;
|
package com.leandog.brazenhead.json;
public class CommandDeserializer implements JsonDeserializer<Command> {
@Override
public Command deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
Command command = new Command(getName(jsonObject), getArguments(jsonObject, context));
command.setVariable(getVariable(jsonObject));
command.setTarget(getTarget(jsonObject, context));
return command;
}
private String getVariable(JsonObject jsonObject) {
JsonElement variable = jsonObject.get("variable");
return (variable != null) ? variable.getAsString() : null;
}
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
// Path: driver/src/com/leandog/brazenhead/json/CommandDeserializer.java
import java.lang.reflect.Type;
import com.google.brazenhead.gson.*;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.commands.Command.Target;
package com.leandog.brazenhead.json;
public class CommandDeserializer implements JsonDeserializer<Command> {
@Override
public Command deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
Command command = new Command(getName(jsonObject), getArguments(jsonObject, context));
command.setVariable(getVariable(jsonObject));
command.setTarget(getTarget(jsonObject, context));
return command;
}
private String getVariable(JsonObject jsonObject) {
JsonElement variable = jsonObject.get("variable");
return (variable != null) ? variable.getAsString() : null;
}
|
private Target getTarget(JsonObject jsonObject, JsonDeserializationContext context) {
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/ListItemFinderTest.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.*;
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
|
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class ListItemFinderTest {
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
// Path: units/src/com/leandog/brazenhead/ListItemFinderTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.*;
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class ListItemFinderTest {
|
@RunWith(BrazenheadTestRunner.class)
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/ListItemFinderTest.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.*;
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
|
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class ListItemFinderTest {
@RunWith(BrazenheadTestRunner.class)
public static class FindingByIndex {
@Spy InstrumentationStub instrumentation = new InstrumentationStub();
@Mock ArrayList<ListView> theLists;
@Mock ListView theFirstList;
@Mock ListView theSecondList;
@Mock Solo solo;
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
// Path: units/src/com/leandog/brazenhead/ListItemFinderTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.*;
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
package com.leandog.brazenhead;
@RunWith(Enclosed.class)
public class ListItemFinderTest {
@RunWith(BrazenheadTestRunner.class)
public static class FindingByIndex {
@Spy InstrumentationStub instrumentation = new InstrumentationStub();
@Mock ArrayList<ListView> theLists;
@Mock ListView theFirstList;
@Mock ListView theSecondList;
@Mock Solo solo;
|
@Mock BrazenheadSleeper sleeper;
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/ListItemFinderTest.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.*;
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
|
if (throwOnKeyEvents) {
throw new SecurityException();
}
super.sendKeyDownUpSync(key);
}
public void setToThrowOnKeyEvents() {
throwOnKeyEvents = true;
}
}
}
@RunWith(BrazenheadTestRunner.class)
public static class FindingByText {
@Mock Instrumentation instrumentation;
@Mock Solo solo;
@Mock TextView theFoundText;
@Mock BrazenheadSleeper sleeper;
private ListItemFinder listItemFinder;
@Before
public void setUp() {
TestRunInformation.setSolo(solo);
when(solo.waitForText(anyString())).thenReturn(true);
listItemFinder = new ListItemFinder(instrumentation, solo, sleeper);
}
@Test
|
// Path: driver/src/com/leandog/brazenhead/exceptions/IsNotAListViewItem.java
// @SuppressWarnings("unused")
// public class IsNotAListViewItem extends Exception {
// private static final long serialVersionUID = 1L;
// private final View theView;
//
// public IsNotAListViewItem(final View theView) {
// this.theView = theView;
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
//
// Path: driver/src/com/robotium/solo/BrazenheadSleeper.java
// public class BrazenheadSleeper extends Sleeper {
//
// @Override
// public void sleep() {
// super.sleep();
// }
//
// @Override
// public void sleepMini() {
// super.sleepMini();
// }
// }
// Path: units/src/com/leandog/brazenhead/ListItemFinderTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.mockito.*;
import android.app.Instrumentation;
import android.view.*;
import android.widget.*;
import com.leandog.brazenhead.exceptions.IsNotAListViewItem;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.BrazenheadSleeper;
import com.robotium.solo.Solo;
if (throwOnKeyEvents) {
throw new SecurityException();
}
super.sendKeyDownUpSync(key);
}
public void setToThrowOnKeyEvents() {
throwOnKeyEvents = true;
}
}
}
@RunWith(BrazenheadTestRunner.class)
public static class FindingByText {
@Mock Instrumentation instrumentation;
@Mock Solo solo;
@Mock TextView theFoundText;
@Mock BrazenheadSleeper sleeper;
private ListItemFinder listItemFinder;
@Before
public void setUp() {
TestRunInformation.setSolo(solo);
when(solo.waitForText(anyString())).thenReturn(true);
listItemFinder = new ListItemFinder(instrumentation, solo, sleeper);
}
@Test
|
public void itIndicatesIfNoTextIsFound() throws IsNotAListViewItem {
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
|
import com.leandog.brazenhead.commands.Command;
|
package com.leandog.brazenhead.exceptions;
public class CommandNotFoundException extends Exception {
private static final long serialVersionUID = 1L;
public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
super(missingCommandMessage(methodName, targetClass, arguments));
}
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
import com.leandog.brazenhead.commands.Command;
package com.leandog.brazenhead.exceptions;
public class CommandNotFoundException extends Exception {
private static final long serialVersionUID = 1L;
public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
super(missingCommandMessage(methodName, targetClass, arguments));
}
|
public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/commands/CommandRunner.java
|
// Path: driver/src/com/leandog/brazenhead/TestRunInformation.java
// public class TestRunInformation {
//
// private static String packageName;
// private static String fullLauncherName;
// private static Solo robotium;
// private static Brazenhead brazenhead;
//
// public static void initialize(final Bundle arguments) {
// if( null == arguments ) return;
// packageName = arguments.getString("packageName");
// fullLauncherName = arguments.getString("fullLauncherName");
// }
//
// public static String getPackageName() {
// return packageName;
// }
//
// public static String getFullLauncherName() {
// return fullLauncherName;
// }
//
// public static void setSolo(final Solo solo) {
// robotium = solo;
// }
//
// public static Solo getSolo() {
// return robotium;
// }
//
// public static Brazenhead getBrazenhead() {
// return brazenhead;
// }
//
// public static void setBrazenhead(Brazenhead brazenheadInstance) {
// brazenhead = brazenheadInstance;
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
|
import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
import com.leandog.brazenhead.TestRunInformation;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
|
package com.leandog.brazenhead.commands;
public class CommandRunner {
private Object theLastResult;
Map<String, Object> variables = new HashMap<String, Object>();
public void execute(final Command... commands) throws Exception {
clearLastRun();
for (final Command command : commands) {
theLastResult = findMethod(command).invoke(theTargetFor(command), theArguments(command));
if (command.hasVariable()) {
storeVariable(command);
}
}
}
public Object theLastResult() {
return theLastResult;
}
|
// Path: driver/src/com/leandog/brazenhead/TestRunInformation.java
// public class TestRunInformation {
//
// private static String packageName;
// private static String fullLauncherName;
// private static Solo robotium;
// private static Brazenhead brazenhead;
//
// public static void initialize(final Bundle arguments) {
// if( null == arguments ) return;
// packageName = arguments.getString("packageName");
// fullLauncherName = arguments.getString("fullLauncherName");
// }
//
// public static String getPackageName() {
// return packageName;
// }
//
// public static String getFullLauncherName() {
// return fullLauncherName;
// }
//
// public static void setSolo(final Solo solo) {
// robotium = solo;
// }
//
// public static Solo getSolo() {
// return robotium;
// }
//
// public static Brazenhead getBrazenhead() {
// return brazenhead;
// }
//
// public static void setBrazenhead(Brazenhead brazenheadInstance) {
// brazenhead = brazenheadInstance;
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
// Path: driver/src/com/leandog/brazenhead/commands/CommandRunner.java
import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
import com.leandog.brazenhead.TestRunInformation;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
package com.leandog.brazenhead.commands;
public class CommandRunner {
private Object theLastResult;
Map<String, Object> variables = new HashMap<String, Object>();
public void execute(final Command... commands) throws Exception {
clearLastRun();
for (final Command command : commands) {
theLastResult = findMethod(command).invoke(theTargetFor(command), theArguments(command));
if (command.hasVariable()) {
storeVariable(command);
}
}
}
public Object theLastResult() {
return theLastResult;
}
|
private Method findMethod(final Command command) throws CommandNotFoundException {
|
leandog/brazenhead
|
driver/src/com/leandog/brazenhead/commands/CommandRunner.java
|
// Path: driver/src/com/leandog/brazenhead/TestRunInformation.java
// public class TestRunInformation {
//
// private static String packageName;
// private static String fullLauncherName;
// private static Solo robotium;
// private static Brazenhead brazenhead;
//
// public static void initialize(final Bundle arguments) {
// if( null == arguments ) return;
// packageName = arguments.getString("packageName");
// fullLauncherName = arguments.getString("fullLauncherName");
// }
//
// public static String getPackageName() {
// return packageName;
// }
//
// public static String getFullLauncherName() {
// return fullLauncherName;
// }
//
// public static void setSolo(final Solo solo) {
// robotium = solo;
// }
//
// public static Solo getSolo() {
// return robotium;
// }
//
// public static Brazenhead getBrazenhead() {
// return brazenhead;
// }
//
// public static void setBrazenhead(Brazenhead brazenheadInstance) {
// brazenhead = brazenheadInstance;
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
|
import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
import com.leandog.brazenhead.TestRunInformation;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
|
package com.leandog.brazenhead.commands;
public class CommandRunner {
private Object theLastResult;
Map<String, Object> variables = new HashMap<String, Object>();
public void execute(final Command... commands) throws Exception {
clearLastRun();
for (final Command command : commands) {
theLastResult = findMethod(command).invoke(theTargetFor(command), theArguments(command));
if (command.hasVariable()) {
storeVariable(command);
}
}
}
public Object theLastResult() {
return theLastResult;
}
private Method findMethod(final Command command) throws CommandNotFoundException {
return new MethodFinder().find(command.getName()).on(theTargetFor(command).getClass()).with(argumentTypesFor(command));
}
private void clearLastRun() {
theLastResult = null;
variables.clear();
}
private Object theTargetFor(final Command command) {
switch (command.getTarget()) {
case Brazenhead:
|
// Path: driver/src/com/leandog/brazenhead/TestRunInformation.java
// public class TestRunInformation {
//
// private static String packageName;
// private static String fullLauncherName;
// private static Solo robotium;
// private static Brazenhead brazenhead;
//
// public static void initialize(final Bundle arguments) {
// if( null == arguments ) return;
// packageName = arguments.getString("packageName");
// fullLauncherName = arguments.getString("fullLauncherName");
// }
//
// public static String getPackageName() {
// return packageName;
// }
//
// public static String getFullLauncherName() {
// return fullLauncherName;
// }
//
// public static void setSolo(final Solo solo) {
// robotium = solo;
// }
//
// public static Solo getSolo() {
// return robotium;
// }
//
// public static Brazenhead getBrazenhead() {
// return brazenhead;
// }
//
// public static void setBrazenhead(Brazenhead brazenheadInstance) {
// brazenhead = brazenheadInstance;
// }
//
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
// Path: driver/src/com/leandog/brazenhead/commands/CommandRunner.java
import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
import com.leandog.brazenhead.TestRunInformation;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
package com.leandog.brazenhead.commands;
public class CommandRunner {
private Object theLastResult;
Map<String, Object> variables = new HashMap<String, Object>();
public void execute(final Command... commands) throws Exception {
clearLastRun();
for (final Command command : commands) {
theLastResult = findMethod(command).invoke(theTargetFor(command), theArguments(command));
if (command.hasVariable()) {
storeVariable(command);
}
}
}
public Object theLastResult() {
return theLastResult;
}
private Method findMethod(final Command command) throws CommandNotFoundException {
return new MethodFinder().find(command.getName()).on(theTargetFor(command).getClass()).with(argumentTypesFor(command));
}
private void clearLastRun() {
theLastResult = null;
variables.clear();
}
private Object theTargetFor(final Command command) {
switch (command.getTarget()) {
case Brazenhead:
|
return TestRunInformation.getBrazenhead();
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/exceptions/CommandNotFoundExceptionTest.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
|
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
import org.junit.Test;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
|
package com.leandog.brazenhead.exceptions;
public class CommandNotFoundExceptionTest {
Command theCommand = new Command("theCommandMethod");
@Test
public void itIndicatedWhichMethodWasNotFound() {
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public class Command {
//
// private String name;
// private Object[] arguments;
// private Target target;
// private String variable;
//
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
//
// public Command() {
// name = null;
// arguments = new Object[0];
// target = Target.LastResultOrRobotium;
// }
//
// public Command(final String name) {
// this();
// this.name = name;
// }
//
// public Command(final String name, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// }
//
// public Command(final String name, final Target target, final Object... arguments) {
// this();
// this.name = name;
// this.arguments = arguments;
// setTarget(target);
// }
//
// public String getName() {
// return name;
// }
//
// public Object[] getArguments() {
// return arguments;
// }
//
// public Target getTarget() {
// return target;
// }
//
// public String variableName() {
// return variable;
// }
//
// public void setVariable(final String variable) {
// if( null != variable && !variable.matches("@@.*@@")) {
// throw new IllegalVariableArgumentException();
// }
// this.variable = variable;
// }
//
// public void setTarget(final Target target) {
// if (target != null) {
// this.target = target;
// }
// }
//
// public boolean hasVariable() {
// return variable != null;
// }
//
// public String getVariable() {
// return variable;
// }
//
// @Override
// public int hashCode() {
// return name.hashCode() + Arrays.hashCode(arguments);
// }
//
// @Override
// public boolean equals(Object other) {
// if (null == other || !(other instanceof Command)) {
// return false;
// }
//
// final Command otherCommand = (Command) other;
// return Objects.equal(name, otherCommand.getName()) && Arrays.equals(arguments, otherCommand.getArguments());
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
// Path: units/src/com/leandog/brazenhead/exceptions/CommandNotFoundExceptionTest.java
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
import org.junit.Test;
import com.leandog.brazenhead.commands.Command;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
package com.leandog.brazenhead.exceptions;
public class CommandNotFoundExceptionTest {
Command theCommand = new Command("theCommandMethod");
@Test
public void itIndicatedWhichMethodWasNotFound() {
|
final CommandNotFoundException exception = new CommandNotFoundException(theCommand, "");
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/BrazenheadRequestHandlerTest.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/json/ExceptionSerializer.java
// public class ExceptionSummary {
//
// public final String exception;
// public final String errorMessage;
//
// public final ExceptionSummary theCause;
//
// public ExceptionSummary(final Throwable exception) {
// this.exception = exception.getClass().getName();
// this.errorMessage = exception.getMessage();
// this.theCause = theCause(exception);
// }
//
// private ExceptionSummary theCause(final Throwable exception) {
// Throwable cause = exception.getCause();
// if (null == cause) {
// return null;
// }
//
// return new ExceptionSummary(exception.getCause());
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.io.*;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.*;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.*;
import com.google.brazenhead.gson.Gson;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
import com.leandog.brazenhead.json.ExceptionSerializer.ExceptionSummary;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.Solo;
|
assertIsJson(jsonArg);
assertHasFields(jsonArg.getValue(), "hasDrawable");
}
@Test
public void itCanInvokeCommandsWithIntegers() throws Exception {
post(new Command("clickInList", 7));
verify(solo).clickInList(7);
}
@Test
public void itCanInvokeCommandsWithFloats() throws Exception {
post(new Command("clickLongOnScreen", 1.23f, 4.56f));
verify(solo).clickLongOnScreen(1.23f, 4.56f);
}
@Test
public void itCanInvokeCommandsWithStrings() throws Exception {
post(new Command("clickOnMenuItem", "something"));
verify(solo).clickOnMenuItem("something");
}
@Test
public void itCanHandleErrorsThrownFromCommands() throws Exception {
post(new Command("shouldNotExist"));
ArgumentCaptor<String> responseArg = ArgumentCaptor.forClass(String.class);
verify(responseWriter).print(responseArg.capture());
|
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/json/ExceptionSerializer.java
// public class ExceptionSummary {
//
// public final String exception;
// public final String errorMessage;
//
// public final ExceptionSummary theCause;
//
// public ExceptionSummary(final Throwable exception) {
// this.exception = exception.getClass().getName();
// this.errorMessage = exception.getMessage();
// this.theCause = theCause(exception);
// }
//
// private ExceptionSummary theCause(final Throwable exception) {
// Throwable cause = exception.getCause();
// if (null == cause) {
// return null;
// }
//
// return new ExceptionSummary(exception.getCause());
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
// Path: units/src/com/leandog/brazenhead/BrazenheadRequestHandlerTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.io.*;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.*;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.*;
import com.google.brazenhead.gson.Gson;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
import com.leandog.brazenhead.json.ExceptionSerializer.ExceptionSummary;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.Solo;
assertIsJson(jsonArg);
assertHasFields(jsonArg.getValue(), "hasDrawable");
}
@Test
public void itCanInvokeCommandsWithIntegers() throws Exception {
post(new Command("clickInList", 7));
verify(solo).clickInList(7);
}
@Test
public void itCanInvokeCommandsWithFloats() throws Exception {
post(new Command("clickLongOnScreen", 1.23f, 4.56f));
verify(solo).clickLongOnScreen(1.23f, 4.56f);
}
@Test
public void itCanInvokeCommandsWithStrings() throws Exception {
post(new Command("clickOnMenuItem", "something"));
verify(solo).clickOnMenuItem("something");
}
@Test
public void itCanHandleErrorsThrownFromCommands() throws Exception {
post(new Command("shouldNotExist"));
ArgumentCaptor<String> responseArg = ArgumentCaptor.forClass(String.class);
verify(responseWriter).print(responseArg.capture());
|
final ExceptionSummary summary = new Gson().fromJson(responseArg.getValue(), ExceptionSummary.class);
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/BrazenheadRequestHandlerTest.java
|
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/json/ExceptionSerializer.java
// public class ExceptionSummary {
//
// public final String exception;
// public final String errorMessage;
//
// public final ExceptionSummary theCause;
//
// public ExceptionSummary(final Throwable exception) {
// this.exception = exception.getClass().getName();
// this.errorMessage = exception.getMessage();
// this.theCause = theCause(exception);
// }
//
// private ExceptionSummary theCause(final Throwable exception) {
// Throwable cause = exception.getCause();
// if (null == cause) {
// return null;
// }
//
// return new ExceptionSummary(exception.getCause());
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.io.*;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.*;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.*;
import com.google.brazenhead.gson.Gson;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
import com.leandog.brazenhead.json.ExceptionSerializer.ExceptionSummary;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.Solo;
|
assertIsJson(jsonArg);
assertHasFields(jsonArg.getValue(), "hasDrawable");
}
@Test
public void itCanInvokeCommandsWithIntegers() throws Exception {
post(new Command("clickInList", 7));
verify(solo).clickInList(7);
}
@Test
public void itCanInvokeCommandsWithFloats() throws Exception {
post(new Command("clickLongOnScreen", 1.23f, 4.56f));
verify(solo).clickLongOnScreen(1.23f, 4.56f);
}
@Test
public void itCanInvokeCommandsWithStrings() throws Exception {
post(new Command("clickOnMenuItem", "something"));
verify(solo).clickOnMenuItem("something");
}
@Test
public void itCanHandleErrorsThrownFromCommands() throws Exception {
post(new Command("shouldNotExist"));
ArgumentCaptor<String> responseArg = ArgumentCaptor.forClass(String.class);
verify(responseWriter).print(responseArg.capture());
final ExceptionSummary summary = new Gson().fromJson(responseArg.getValue(), ExceptionSummary.class);
|
// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// super(missingCommandMessage(methodName, targetClass, arguments));
// }
//
// public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
// super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
// }
//
// private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
// return String.format("The %s%s method was not found on %s.",
// methodName,
// stringFor(arguments),
// targetClass.getName());
// }
//
// private static String stringFor(Class<?>[] arguments) {
// if (arguments.length == 0) {
// return "()";
// }
//
// final StringBuilder messageBuilder = new StringBuilder();
// messageBuilder.append("(");
// for (final Class<?> argumentType : arguments) {
// messageBuilder.append(argumentType.getName() + ", ");
// }
//
// messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
// return messageBuilder.toString();
// }
//
// private static int last(final StringBuilder messageBuilder, int count) {
// return messageBuilder.length() - count;
// }
// }
//
// Path: driver/src/com/leandog/brazenhead/json/ExceptionSerializer.java
// public class ExceptionSummary {
//
// public final String exception;
// public final String errorMessage;
//
// public final ExceptionSummary theCause;
//
// public ExceptionSummary(final Throwable exception) {
// this.exception = exception.getClass().getName();
// this.errorMessage = exception.getMessage();
// this.theCause = theCause(exception);
// }
//
// private ExceptionSummary theCause(final Throwable exception) {
// Throwable cause = exception.getCause();
// if (null == cause) {
// return null;
// }
//
// return new ExceptionSummary(exception.getCause());
// }
//
// }
//
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
//
// public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
// super(testClass, new File("../driver"));
// }
//
// @Override
// public Object createTest() throws Exception {
// Object theTest = super.createTest();
// MockitoAnnotations.initMocks(theTest);
// return theTest;
// }
//
// @Override
// public void beforeTest(Method method) {
// bindShadowClass(ShadowInstrumentationTestCase.class);
// }
//
// }
// Path: units/src/com/leandog/brazenhead/BrazenheadRequestHandlerTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.io.*;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.*;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.*;
import com.google.brazenhead.gson.Gson;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
import com.leandog.brazenhead.json.ExceptionSerializer.ExceptionSummary;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.Solo;
assertIsJson(jsonArg);
assertHasFields(jsonArg.getValue(), "hasDrawable");
}
@Test
public void itCanInvokeCommandsWithIntegers() throws Exception {
post(new Command("clickInList", 7));
verify(solo).clickInList(7);
}
@Test
public void itCanInvokeCommandsWithFloats() throws Exception {
post(new Command("clickLongOnScreen", 1.23f, 4.56f));
verify(solo).clickLongOnScreen(1.23f, 4.56f);
}
@Test
public void itCanInvokeCommandsWithStrings() throws Exception {
post(new Command("clickOnMenuItem", "something"));
verify(solo).clickOnMenuItem("something");
}
@Test
public void itCanHandleErrorsThrownFromCommands() throws Exception {
post(new Command("shouldNotExist"));
ArgumentCaptor<String> responseArg = ArgumentCaptor.forClass(String.class);
verify(responseWriter).print(responseArg.capture());
final ExceptionSummary summary = new Gson().fromJson(responseArg.getValue(), ExceptionSummary.class);
|
assertThat(summary.exception, is(CommandNotFoundException.class.getName()));
|
leandog/brazenhead
|
units/src/com/leandog/brazenhead/commands/CommandRunnerTest.java
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
|
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.mockito.*;
import com.leandog.brazenhead.*;
import com.leandog.brazenhead.commands.Command.Target;
import com.robotium.solo.Solo;
|
verify(solo).clickLongOnScreen(1.0f, 2.0f);
}
@Test
public void itCanInvokeMethodsTakingAString() throws Exception {
commandRunner.execute(new Command("clickLongOnText", "someText"));
verify(solo).clickLongOnText("someText");
}
@Test
public void itCanChainMethodCallsFromTheLastResult() throws Exception {
commandRunner.execute(new Command("getClass"), new Command("getName"));
assertThat(commandRunner.theLastResult(), equalTo((Object)solo.getClass().getName()));
}
@Test
public void itCanInvokeMethodsTakingABoolean() throws Exception {
commandRunner.execute(new Command("clickOnText", "someText", 123, true));
verify(solo).clickOnText("someText", 123, true);
}
@Test
public void itClearsTheLastResultBeforeExecutingAgain() throws Exception {
commandRunner.execute(new Command("clickInList", 0));
commandRunner.execute(new Command("clickInList", 0));
verify(solo, times(2)).clickInList(0);
}
@Test
public void itCanDesignateTheRobotiumTarget() throws Exception {
|
// Path: driver/src/com/leandog/brazenhead/commands/Command.java
// public enum Target {
// LastResultOrRobotium, Robotium, Brazenhead,
// }
// Path: units/src/com/leandog/brazenhead/commands/CommandRunnerTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.*;
import org.mockito.*;
import com.leandog.brazenhead.*;
import com.leandog.brazenhead.commands.Command.Target;
import com.robotium.solo.Solo;
verify(solo).clickLongOnScreen(1.0f, 2.0f);
}
@Test
public void itCanInvokeMethodsTakingAString() throws Exception {
commandRunner.execute(new Command("clickLongOnText", "someText"));
verify(solo).clickLongOnText("someText");
}
@Test
public void itCanChainMethodCallsFromTheLastResult() throws Exception {
commandRunner.execute(new Command("getClass"), new Command("getName"));
assertThat(commandRunner.theLastResult(), equalTo((Object)solo.getClass().getName()));
}
@Test
public void itCanInvokeMethodsTakingABoolean() throws Exception {
commandRunner.execute(new Command("clickOnText", "someText", 123, true));
verify(solo).clickOnText("someText", 123, true);
}
@Test
public void itClearsTheLastResultBeforeExecutingAgain() throws Exception {
commandRunner.execute(new Command("clickInList", 0));
commandRunner.execute(new Command("clickInList", 0));
verify(solo, times(2)).clickInList(0);
}
@Test
public void itCanDesignateTheRobotiumTarget() throws Exception {
|
commandRunner.execute(new Command("clickInList", Target.Robotium, 0), new Command("clickInList", Target.Robotium, 0));
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/ScrollToPositionAction.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class ScrollToPositionAction extends Action {
private int position;
public ScrollToPositionAction(int position) {
this.position = position;
}
public int getPosition() {
return position;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ScrollToPositionAction.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class ScrollToPositionAction extends Action {
private int position;
public ScrollToPositionAction(int position) {
this.position = position;
}
public int getPosition() {
return position;
}
|
public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/EventWriter.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
|
import android.util.Log;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.vpedak.testsrecorder.core;
public class EventWriter {
private long uniqueId;
public static final String ANDRIOD_TEST_RECORDER = "AndriodTestRecorder";
public String tag;
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/EventWriter.java
import android.util.Log;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.vpedak.testsrecorder.core;
public class EventWriter {
private long uniqueId;
public static final String ANDRIOD_TEST_RECORDER = "AndriodTestRecorder";
public String tag;
|
private Map<String, RecordingEvent> delayedEvents = new HashMap<String, RecordingEvent>();
|
vpedak/droidtestrec
|
src/com/vpedak/testsrecorder/plugin/core/EventReader.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/EventWriter.java
// public class EventWriter {
// private long uniqueId;
// public static final String ANDRIOD_TEST_RECORDER = "AndriodTestRecorder";
// public String tag;
// private Map<String, RecordingEvent> delayedEvents = new HashMap<String, RecordingEvent>();
// private EventWriterListener listener;
// private long lastTime;
//
// public EventWriter(long uniqueId, EventWriterListener listener) {
// this.uniqueId = uniqueId;
// this.listener = listener;
// tag = ANDRIOD_TEST_RECORDER+uniqueId;
// lastTime = System.currentTimeMillis();
// }
//
// public synchronized void writeEvent(RecordingEvent event) {
// long diff = System.currentTimeMillis() - lastTime;
// lastTime = System.currentTimeMillis();
//
// if (delayedEvents.size() > 0) {
// for(RecordingEvent delayedEvent : delayedEvents.values()) {
// delayedEvent.setTime(diff);
// Log.d(tag, delayedEvent.toString());
// }
// delayedEvents.clear();
// }
// event.setTime(diff);
// Log.d(tag, event.toString());
// listener.onEventWritten();
// }
//
// public synchronized void addDelayedEvent(String id, RecordingEvent delayedEvent) {
// delayedEvents.put(id, delayedEvent);
// }
//
// public interface EventWriterListener {
// void onEventWritten();
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
|
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.logcat.LogCatListener;
import com.android.ddmlib.logcat.LogCatMessage;
import com.android.ddmlib.logcat.LogCatReceiverTask;
import com.vpedak.testsrecorder.core.EventWriter;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
|
package com.vpedak.testsrecorder.plugin.core;
public class EventReader {
private EventListener eventListener;
private LogCatReceiverTask receiverTask;
private AndroidDebugBridge bridge;
private Thread thread;
public EventReader(EventListener eventListener) {
this.eventListener = eventListener;
AndroidDebugBridge.init(false);
}
public void start(long uniqueId) {
bridge = AndroidDebugBridge.createBridge();
int count = 0;
while (bridge.hasInitialDeviceList() == false) {
try {
Thread.sleep(100);
count++;
} catch (InterruptedException e) {
}
if (count > 100) {
throw new RuntimeException("Timeout connecting to the adb!");
}
}
IDevice[] devices = bridge.getDevices();
if (devices.length == 0) {
throw new RuntimeException("Failed to find device");
}
IDevice device = devices[0];
receiverTask = new LogCatReceiverTask(device);
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/EventWriter.java
// public class EventWriter {
// private long uniqueId;
// public static final String ANDRIOD_TEST_RECORDER = "AndriodTestRecorder";
// public String tag;
// private Map<String, RecordingEvent> delayedEvents = new HashMap<String, RecordingEvent>();
// private EventWriterListener listener;
// private long lastTime;
//
// public EventWriter(long uniqueId, EventWriterListener listener) {
// this.uniqueId = uniqueId;
// this.listener = listener;
// tag = ANDRIOD_TEST_RECORDER+uniqueId;
// lastTime = System.currentTimeMillis();
// }
//
// public synchronized void writeEvent(RecordingEvent event) {
// long diff = System.currentTimeMillis() - lastTime;
// lastTime = System.currentTimeMillis();
//
// if (delayedEvents.size() > 0) {
// for(RecordingEvent delayedEvent : delayedEvents.values()) {
// delayedEvent.setTime(diff);
// Log.d(tag, delayedEvent.toString());
// }
// delayedEvents.clear();
// }
// event.setTime(diff);
// Log.d(tag, event.toString());
// listener.onEventWritten();
// }
//
// public synchronized void addDelayedEvent(String id, RecordingEvent delayedEvent) {
// delayedEvents.put(id, delayedEvent);
// }
//
// public interface EventWriterListener {
// void onEventWritten();
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
// Path: src/com/vpedak/testsrecorder/plugin/core/EventReader.java
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.logcat.LogCatListener;
import com.android.ddmlib.logcat.LogCatMessage;
import com.android.ddmlib.logcat.LogCatReceiverTask;
import com.vpedak.testsrecorder.core.EventWriter;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
package com.vpedak.testsrecorder.plugin.core;
public class EventReader {
private EventListener eventListener;
private LogCatReceiverTask receiverTask;
private AndroidDebugBridge bridge;
private Thread thread;
public EventReader(EventListener eventListener) {
this.eventListener = eventListener;
AndroidDebugBridge.init(false);
}
public void start(long uniqueId) {
bridge = AndroidDebugBridge.createBridge();
int count = 0;
while (bridge.hasInitialDeviceList() == false) {
try {
Thread.sleep(100);
count++;
} catch (InterruptedException e) {
}
if (count > 100) {
throw new RuntimeException("Timeout connecting to the adb!");
}
}
IDevice[] devices = bridge.getDevices();
if (devices.length == 0) {
throw new RuntimeException("Failed to find device");
}
IDevice device = devices[0];
receiverTask = new LogCatReceiverTask(device);
|
final String tag = EventWriter.ANDRIOD_TEST_RECORDER+uniqueId;
|
vpedak/droidtestrec
|
src/com/vpedak/testsrecorder/plugin/core/EventReader.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/EventWriter.java
// public class EventWriter {
// private long uniqueId;
// public static final String ANDRIOD_TEST_RECORDER = "AndriodTestRecorder";
// public String tag;
// private Map<String, RecordingEvent> delayedEvents = new HashMap<String, RecordingEvent>();
// private EventWriterListener listener;
// private long lastTime;
//
// public EventWriter(long uniqueId, EventWriterListener listener) {
// this.uniqueId = uniqueId;
// this.listener = listener;
// tag = ANDRIOD_TEST_RECORDER+uniqueId;
// lastTime = System.currentTimeMillis();
// }
//
// public synchronized void writeEvent(RecordingEvent event) {
// long diff = System.currentTimeMillis() - lastTime;
// lastTime = System.currentTimeMillis();
//
// if (delayedEvents.size() > 0) {
// for(RecordingEvent delayedEvent : delayedEvents.values()) {
// delayedEvent.setTime(diff);
// Log.d(tag, delayedEvent.toString());
// }
// delayedEvents.clear();
// }
// event.setTime(diff);
// Log.d(tag, event.toString());
// listener.onEventWritten();
// }
//
// public synchronized void addDelayedEvent(String id, RecordingEvent delayedEvent) {
// delayedEvents.put(id, delayedEvent);
// }
//
// public interface EventWriterListener {
// void onEventWritten();
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
|
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.logcat.LogCatListener;
import com.android.ddmlib.logcat.LogCatMessage;
import com.android.ddmlib.logcat.LogCatReceiverTask;
import com.vpedak.testsrecorder.core.EventWriter;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
|
int count = 0;
while (bridge.hasInitialDeviceList() == false) {
try {
Thread.sleep(100);
count++;
} catch (InterruptedException e) {
}
if (count > 100) {
throw new RuntimeException("Timeout connecting to the adb!");
}
}
IDevice[] devices = bridge.getDevices();
if (devices.length == 0) {
throw new RuntimeException("Failed to find device");
}
IDevice device = devices[0];
receiverTask = new LogCatReceiverTask(device);
final String tag = EventWriter.ANDRIOD_TEST_RECORDER+uniqueId;
receiverTask.addLogCatListener(new LogCatListener() {
@Override
public void log(List<LogCatMessage> list) {
for (LogCatMessage message : list) {
if (tag.equals(message.getTag())) {
String str = message.getMessage();
try {
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/EventWriter.java
// public class EventWriter {
// private long uniqueId;
// public static final String ANDRIOD_TEST_RECORDER = "AndriodTestRecorder";
// public String tag;
// private Map<String, RecordingEvent> delayedEvents = new HashMap<String, RecordingEvent>();
// private EventWriterListener listener;
// private long lastTime;
//
// public EventWriter(long uniqueId, EventWriterListener listener) {
// this.uniqueId = uniqueId;
// this.listener = listener;
// tag = ANDRIOD_TEST_RECORDER+uniqueId;
// lastTime = System.currentTimeMillis();
// }
//
// public synchronized void writeEvent(RecordingEvent event) {
// long diff = System.currentTimeMillis() - lastTime;
// lastTime = System.currentTimeMillis();
//
// if (delayedEvents.size() > 0) {
// for(RecordingEvent delayedEvent : delayedEvents.values()) {
// delayedEvent.setTime(diff);
// Log.d(tag, delayedEvent.toString());
// }
// delayedEvents.clear();
// }
// event.setTime(diff);
// Log.d(tag, event.toString());
// listener.onEventWritten();
// }
//
// public synchronized void addDelayedEvent(String id, RecordingEvent delayedEvent) {
// delayedEvents.put(id, delayedEvent);
// }
//
// public interface EventWriterListener {
// void onEventWritten();
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
// Path: src/com/vpedak/testsrecorder/plugin/core/EventReader.java
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.logcat.LogCatListener;
import com.android.ddmlib.logcat.LogCatMessage;
import com.android.ddmlib.logcat.LogCatReceiverTask;
import com.vpedak.testsrecorder.core.EventWriter;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
int count = 0;
while (bridge.hasInitialDeviceList() == false) {
try {
Thread.sleep(100);
count++;
} catch (InterruptedException e) {
}
if (count > 100) {
throw new RuntimeException("Timeout connecting to the adb!");
}
}
IDevice[] devices = bridge.getDevices();
if (devices.length == 0) {
throw new RuntimeException("Failed to find device");
}
IDevice device = devices[0];
receiverTask = new LogCatReceiverTask(device);
final String tag = EventWriter.ANDRIOD_TEST_RECORDER+uniqueId;
receiverTask.addLogCatListener(new LogCatListener() {
@Override
public void log(List<LogCatMessage> list) {
for (LogCatMessage message : list) {
if (tag.equals(message.getTag())) {
String str = message.getMessage();
try {
|
RecordingEvent event = RecordingEvent.fromString(str);
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/ParentIdView.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class ParentIdView extends Subject {
private String parentId;
private String childId;
public ParentIdView(String parentId, String childId) {
this.parentId = parentId;
this.childId = childId;
}
public String getParentId() {
return parentId;
}
public String getChildId() {
return childId;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ParentIdView.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class ParentIdView extends Subject {
private String parentId;
private String childId;
public ParentIdView(String parentId, String childId) {
this.parentId = parentId;
this.childId = childId;
}
public String getParentId() {
return parentId;
}
public String getChildId() {
return childId;
}
|
public void accept(StringBuilder sb, TestGenerator generator){
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/ActivityListener.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/PressBackAction.java
// public class PressBackAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
|
import android.app.Activity;
import android.app.Instrumentation;
import android.content.IntentFilter;
import android.os.Looper;
import android.util.Log;
import android.util.Printer;
import com.vpedak.testsrecorder.core.events.PressBackAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
import java.util.EmptyStackException;
import java.util.Stack;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
|
activityProcessor = new ActivityProcessor(uniqueId, instr, eventWriter);
activityProcessor.processActivity(activity);
try {
fResumed = Activity.class.getDeclaredField("mResumed");
fResumed.setAccessible(true);
fStopped = Activity.class.getDeclaredField("mStopped");
fStopped.setAccessible(true);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
}
public void start() {
new Timer().schedule(new ActivityTask(this), 300L, 300L);
}
public synchronized void check() {
Activity test = monitor.getLastActivity();
if (test != null && test != activity && !isStopped(test)) {
boolean push = true;
if (isResumed(test)) {
try {
if (stack.peek().equals(test) ) {
stack.pop();
push = false;
if (!wasEvent) {
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/PressBackAction.java
// public class PressBackAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/ActivityListener.java
import android.app.Activity;
import android.app.Instrumentation;
import android.content.IntentFilter;
import android.os.Looper;
import android.util.Log;
import android.util.Printer;
import com.vpedak.testsrecorder.core.events.PressBackAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
import java.util.EmptyStackException;
import java.util.Stack;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
activityProcessor = new ActivityProcessor(uniqueId, instr, eventWriter);
activityProcessor.processActivity(activity);
try {
fResumed = Activity.class.getDeclaredField("mResumed");
fResumed.setAccessible(true);
fStopped = Activity.class.getDeclaredField("mStopped");
fStopped.setAccessible(true);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
}
public void start() {
new Timer().schedule(new ActivityTask(this), 300L, 300L);
}
public synchronized void check() {
Activity test = monitor.getLastActivity();
if (test != null && test != activity && !isStopped(test)) {
boolean push = true;
if (isResumed(test)) {
try {
if (stack.peek().equals(test) ) {
stack.pop();
push = false;
if (!wasEvent) {
|
eventWriter.writeEvent(new RecordingEvent(new Espresso(), new PressBackAction(), "Press on the back button"));
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/ActivityListener.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/PressBackAction.java
// public class PressBackAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
|
import android.app.Activity;
import android.app.Instrumentation;
import android.content.IntentFilter;
import android.os.Looper;
import android.util.Log;
import android.util.Printer;
import com.vpedak.testsrecorder.core.events.PressBackAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
import java.util.EmptyStackException;
import java.util.Stack;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
|
activityProcessor = new ActivityProcessor(uniqueId, instr, eventWriter);
activityProcessor.processActivity(activity);
try {
fResumed = Activity.class.getDeclaredField("mResumed");
fResumed.setAccessible(true);
fStopped = Activity.class.getDeclaredField("mStopped");
fStopped.setAccessible(true);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
}
public void start() {
new Timer().schedule(new ActivityTask(this), 300L, 300L);
}
public synchronized void check() {
Activity test = monitor.getLastActivity();
if (test != null && test != activity && !isStopped(test)) {
boolean push = true;
if (isResumed(test)) {
try {
if (stack.peek().equals(test) ) {
stack.pop();
push = false;
if (!wasEvent) {
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/PressBackAction.java
// public class PressBackAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/ActivityListener.java
import android.app.Activity;
import android.app.Instrumentation;
import android.content.IntentFilter;
import android.os.Looper;
import android.util.Log;
import android.util.Printer;
import com.vpedak.testsrecorder.core.events.PressBackAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
import java.util.EmptyStackException;
import java.util.Stack;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
activityProcessor = new ActivityProcessor(uniqueId, instr, eventWriter);
activityProcessor.processActivity(activity);
try {
fResumed = Activity.class.getDeclaredField("mResumed");
fResumed.setAccessible(true);
fStopped = Activity.class.getDeclaredField("mStopped");
fStopped.setAccessible(true);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
}
public void start() {
new Timer().schedule(new ActivityTask(this), 300L, 300L);
}
public synchronized void check() {
Activity test = monitor.getLastActivity();
if (test != null && test != activity && !isStopped(test)) {
boolean push = true;
if (isResumed(test)) {
try {
if (stack.peek().equals(test) ) {
stack.pop();
push = false;
if (!wasEvent) {
|
eventWriter.writeEvent(new RecordingEvent(new Espresso(), new PressBackAction(), "Press on the back button"));
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/SelectViewPagerPageAction.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class SelectViewPagerPageAction extends Action {
private int position;
public SelectViewPagerPageAction(int position) {
this.position = position;
}
public int getPosition() {
return position;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/SelectViewPagerPageAction.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class SelectViewPagerPageAction extends Action {
private int position;
public SelectViewPagerPageAction(int position) {
this.position = position;
}
public int getPosition() {
return position;
}
|
public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class Data extends Subject {
private String adapterId;
private String className;
private String value;
public Data(String adapterId, String className) {
this.adapterId = adapterId;
this.className = className;
}
public Data(String adapterId, String className, String value) {
this.adapterId = adapterId;
this.className = className;
this.value = value;
}
public String getAdapterId() {
return adapterId;
}
public String getClassName() {
return className;
}
public String getValue() {
return value;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class Data extends Subject {
private String adapterId;
private String className;
private String value;
public Data(String adapterId, String className) {
this.adapterId = adapterId;
this.className = className;
}
public Data(String adapterId, String className, String value) {
this.adapterId = adapterId;
this.className = className;
this.value = value;
}
public String getAdapterId() {
return adapterId;
}
public String getClassName() {
return className;
}
public String getValue() {
return value;
}
|
public void accept(StringBuilder sb, TestGenerator generator){
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/Subject.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public abstract class Subject {
public void accept(StringBuilder sb, TestGenerator generator){
generator.generateSubject(sb, this);
}
@Override
public String toString() {
return Subject.toString(this);
}
public static String toString(Subject subject) {
if (subject instanceof View) {
View view = (View) subject;
return "view=" + view.getId();
} else if (subject instanceof MenuItem) {
MenuItem menuItem = (MenuItem) subject;
return "menuItem=" + menuItem.getId() + "#" + menuItem.getTitle();
} else if (subject instanceof ParentView) {
ParentView parentView = (ParentView) subject;
return "parentView=" + parentView.getParentId() + "#" + parentView.getChildIndex();
} else if (subject instanceof ParentIdView) {
ParentIdView parentView = (ParentIdView) subject;
return "parentIdView=" + parentView.getParentId() + "#" + parentView.getChildId();
} else if (subject instanceof OptionsMenu) {
return "optionsMenu";
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Subject.java
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public abstract class Subject {
public void accept(StringBuilder sb, TestGenerator generator){
generator.generateSubject(sb, this);
}
@Override
public String toString() {
return Subject.toString(this);
}
public static String toString(Subject subject) {
if (subject instanceof View) {
View view = (View) subject;
return "view=" + view.getId();
} else if (subject instanceof MenuItem) {
MenuItem menuItem = (MenuItem) subject;
return "menuItem=" + menuItem.getId() + "#" + menuItem.getTitle();
} else if (subject instanceof ParentView) {
ParentView parentView = (ParentView) subject;
return "parentView=" + parentView.getParentId() + "#" + parentView.getChildIndex();
} else if (subject instanceof ParentIdView) {
ParentIdView parentView = (ParentIdView) subject;
return "parentIdView=" + parentView.getParentId() + "#" + parentView.getChildId();
} else if (subject instanceof OptionsMenu) {
return "optionsMenu";
|
} else if (subject instanceof Espresso) {
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/ParentView.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class ParentView extends Subject {
private String parentId;
private int childIdx;
public ParentView(String parentId, int childIdx) {
this.parentId = parentId;
this.childIdx = childIdx;
}
public String getParentId() {
return parentId;
}
public int getChildIndex() {
return childIdx;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ParentView.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class ParentView extends Subject {
private String parentId;
private int childIdx;
public ParentView(String parentId, int childIdx) {
this.parentId = parentId;
this.childIdx = childIdx;
}
public String getParentId() {
return parentId;
}
public int getChildIndex() {
return childIdx;
}
|
public void accept(StringBuilder sb, TestGenerator generator){
|
vpedak/droidtestrec
|
RecordingLib/test/com/vpedak/testrecorder/core/events/SubjectTest.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
|
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.events.*;
import org.junit.Assert;
import org.junit.Test;
|
package com.vpedak.testrecorder.core.events;
public class SubjectTest {
@Test
public void testSerialization() {
View view = new View("viewId");
Assert.assertEquals("view=viewId", view.toString());
DisplayedView displayedView = new DisplayedView("viewId");
Assert.assertEquals("displayedView=viewId", displayedView.toString());
MenuItem menuItem = new MenuItem("title", "menuId");
Assert.assertEquals("menuItem=menuId#title", menuItem.toString());
ParentView parentView = new ParentView("parentId", 1);
Assert.assertEquals("parentView=parentId#1", parentView.toString());
ParentIdView parentIdView = new ParentIdView("parentId", "childId");
Assert.assertEquals("parentIdView=parentId#childId", parentIdView.toString());
OptionsMenu optionsMenu = new OptionsMenu();
Assert.assertEquals("optionsMenu", optionsMenu.toString());
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
// Path: RecordingLib/test/com/vpedak/testrecorder/core/events/SubjectTest.java
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.events.*;
import org.junit.Assert;
import org.junit.Test;
package com.vpedak.testrecorder.core.events;
public class SubjectTest {
@Test
public void testSerialization() {
View view = new View("viewId");
Assert.assertEquals("view=viewId", view.toString());
DisplayedView displayedView = new DisplayedView("viewId");
Assert.assertEquals("displayedView=viewId", displayedView.toString());
MenuItem menuItem = new MenuItem("title", "menuId");
Assert.assertEquals("menuItem=menuId#title", menuItem.toString());
ParentView parentView = new ParentView("parentId", 1);
Assert.assertEquals("parentView=parentId#1", parentView.toString());
ParentIdView parentIdView = new ParentIdView("parentId", "childId");
Assert.assertEquals("parentIdView=parentId#childId", parentIdView.toString());
OptionsMenu optionsMenu = new OptionsMenu();
Assert.assertEquals("optionsMenu", optionsMenu.toString());
|
Espresso espresso = new Espresso();
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/DisplayedView.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class DisplayedView extends Subject {
private String id;
public DisplayedView(String id) {
this.id = id;
}
public String getId() {
return id;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/DisplayedView.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class DisplayedView extends Subject {
private String id;
public DisplayedView(String id) {
this.id = id;
}
public String getId() {
return id;
}
|
public void accept(StringBuilder sb, TestGenerator generator){
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/ReplaceTextAction.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class ReplaceTextAction extends Action {
private String text;
public ReplaceTextAction(String text) {
this.text = text;
}
public String getText() {
return text;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ReplaceTextAction.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class ReplaceTextAction extends Action {
private String text;
public ReplaceTextAction(String text) {
this.text = text;
}
public String getText() {
return text;
}
|
public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
|
vpedak/droidtestrec
|
src/com/vpedak/testsrecorder/plugin/core/EspressoTestGenerator.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.TestGenerator;
import com.vpedak.testsrecorder.core.events.*;
import java.util.List;
|
}
@Override
public void generateSubject(StringBuilder sb, DisplayedView subject) {
sb.append("onView(allOf(isDisplayed(),withId(").append(subject.getId()).append("))).");
}
@Override
public void generateSubject(StringBuilder sb, OptionsMenu subject) {
sb.append("openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext())");
}
@Override
public void generateSubject(StringBuilder sb, MenuItem subject) {
sb.append("onView(withText(\"").append(subject.getTitle()).append("\")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentView subject) {
wasParentView = true;
sb.append("onView(nthChildOf(withId(").append(subject.getParentId()).append("), ").append(subject.getChildIndex()).append(")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentIdView subject) {
sb.append("onView(allOf(withParent(withId(").append(subject.getParentId()).
append(")), withId(").append(subject.getChildId()).append("))).");
}
@Override
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: src/com/vpedak/testsrecorder/plugin/core/EspressoTestGenerator.java
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.TestGenerator;
import com.vpedak.testsrecorder.core.events.*;
import java.util.List;
}
@Override
public void generateSubject(StringBuilder sb, DisplayedView subject) {
sb.append("onView(allOf(isDisplayed(),withId(").append(subject.getId()).append("))).");
}
@Override
public void generateSubject(StringBuilder sb, OptionsMenu subject) {
sb.append("openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext())");
}
@Override
public void generateSubject(StringBuilder sb, MenuItem subject) {
sb.append("onView(withText(\"").append(subject.getTitle()).append("\")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentView subject) {
wasParentView = true;
sb.append("onView(nthChildOf(withId(").append(subject.getParentId()).append("), ").append(subject.getChildIndex()).append(")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentIdView subject) {
sb.append("onView(allOf(withParent(withId(").append(subject.getParentId()).
append(")), withId(").append(subject.getChildId()).append("))).");
}
@Override
|
public void generateSubject(StringBuilder sb, Data subject) {
|
vpedak/droidtestrec
|
src/com/vpedak/testsrecorder/plugin/core/EspressoTestGenerator.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.TestGenerator;
import com.vpedak.testsrecorder.core.events.*;
import java.util.List;
|
sb.append("onView(withText(\"").append(subject.getTitle()).append("\")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentView subject) {
wasParentView = true;
sb.append("onView(nthChildOf(withId(").append(subject.getParentId()).append("), ").append(subject.getChildIndex()).append(")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentIdView subject) {
sb.append("onView(allOf(withParent(withId(").append(subject.getParentId()).
append(")), withId(").append(subject.getChildId()).append("))).");
}
@Override
public void generateSubject(StringBuilder sb, Data subject) {
if (subject.getValue() != null) {
sb.append("onData(allOf(is(instanceOf(").append(subject.getClassName()).append(".class)), is(\"").
append(subject.getValue()).append("\"))).inAdapterView(withId(").append(subject.getAdapterId()).
append(")).");
} else {
StringBuilder tmp = new StringBuilder(dataTemplate);
replace( tmp, "CLASS", subject.getClassName());
replace( tmp, "ADAPTER_ID", subject.getAdapterId());
sb.append(tmp);
}
}
@Override
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/Espresso.java
// public class Espresso extends Subject {
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: src/com/vpedak/testsrecorder/plugin/core/EspressoTestGenerator.java
import com.vpedak.testsrecorder.core.Espresso;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.TestGenerator;
import com.vpedak.testsrecorder.core.events.*;
import java.util.List;
sb.append("onView(withText(\"").append(subject.getTitle()).append("\")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentView subject) {
wasParentView = true;
sb.append("onView(nthChildOf(withId(").append(subject.getParentId()).append("), ").append(subject.getChildIndex()).append(")).");
}
@Override
public void generateSubject(StringBuilder sb, ParentIdView subject) {
sb.append("onView(allOf(withParent(withId(").append(subject.getParentId()).
append(")), withId(").append(subject.getChildId()).append("))).");
}
@Override
public void generateSubject(StringBuilder sb, Data subject) {
if (subject.getValue() != null) {
sb.append("onData(allOf(is(instanceOf(").append(subject.getClassName()).append(".class)), is(\"").
append(subject.getValue()).append("\"))).inAdapterView(withId(").append(subject.getAdapterId()).
append(")).");
} else {
StringBuilder tmp = new StringBuilder(dataTemplate);
replace( tmp, "CLASS", subject.getClassName());
replace( tmp, "ADAPTER_ID", subject.getAdapterId());
sb.append(tmp);
}
}
@Override
|
public void generateSubject(StringBuilder sb, Espresso subject) {
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/CheckableProcessor.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
|
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
|
package com.vpedak.testsrecorder.core;
public class CheckableProcessor {
private ActivityProcessor activityProcessor;
public CheckableProcessor(ActivityProcessor activityProcessor) {
this.activityProcessor = activityProcessor;
}
public void processClick(final CompoundButton checkable) {
CompoundButton.OnCheckedChangeListener listener = null;
try {
Field f = CompoundButton.class.getDeclaredField("mOnCheckedChangeListener");
f.setAccessible(true);
listener = (CompoundButton.OnCheckedChangeListener) f.get(checkable);
} catch (IllegalAccessException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "IllegalAccessException", e);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
final CompoundButton.OnCheckedChangeListener finalListener = listener;
checkable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
String id = activityProcessor.resolveId(buttonView.getId());
if (id != null) {
String descr = (isChecked ? "Check " : "Uncheck ") + activityProcessor.getWidgetName(buttonView) + " with id "+id;
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/CheckableProcessor.java
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
package com.vpedak.testsrecorder.core;
public class CheckableProcessor {
private ActivityProcessor activityProcessor;
public CheckableProcessor(ActivityProcessor activityProcessor) {
this.activityProcessor = activityProcessor;
}
public void processClick(final CompoundButton checkable) {
CompoundButton.OnCheckedChangeListener listener = null;
try {
Field f = CompoundButton.class.getDeclaredField("mOnCheckedChangeListener");
f.setAccessible(true);
listener = (CompoundButton.OnCheckedChangeListener) f.get(checkable);
} catch (IllegalAccessException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "IllegalAccessException", e);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
final CompoundButton.OnCheckedChangeListener finalListener = listener;
checkable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
String id = activityProcessor.resolveId(buttonView.getId());
if (id != null) {
String descr = (isChecked ? "Check " : "Uncheck ") + activityProcessor.getWidgetName(buttonView) + " with id "+id;
|
activityProcessor.getEventWriter().writeEvent(new RecordingEvent(new com.vpedak.testsrecorder.core.events.View(id), new ClickAction(), descr));
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/CheckableProcessor.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
|
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
|
package com.vpedak.testsrecorder.core;
public class CheckableProcessor {
private ActivityProcessor activityProcessor;
public CheckableProcessor(ActivityProcessor activityProcessor) {
this.activityProcessor = activityProcessor;
}
public void processClick(final CompoundButton checkable) {
CompoundButton.OnCheckedChangeListener listener = null;
try {
Field f = CompoundButton.class.getDeclaredField("mOnCheckedChangeListener");
f.setAccessible(true);
listener = (CompoundButton.OnCheckedChangeListener) f.get(checkable);
} catch (IllegalAccessException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "IllegalAccessException", e);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
final CompoundButton.OnCheckedChangeListener finalListener = listener;
checkable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
String id = activityProcessor.resolveId(buttonView.getId());
if (id != null) {
String descr = (isChecked ? "Check " : "Uncheck ") + activityProcessor.getWidgetName(buttonView) + " with id "+id;
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/CheckableProcessor.java
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import java.lang.reflect.Field;
package com.vpedak.testsrecorder.core;
public class CheckableProcessor {
private ActivityProcessor activityProcessor;
public CheckableProcessor(ActivityProcessor activityProcessor) {
this.activityProcessor = activityProcessor;
}
public void processClick(final CompoundButton checkable) {
CompoundButton.OnCheckedChangeListener listener = null;
try {
Field f = CompoundButton.class.getDeclaredField("mOnCheckedChangeListener");
f.setAccessible(true);
listener = (CompoundButton.OnCheckedChangeListener) f.get(checkable);
} catch (IllegalAccessException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "IllegalAccessException", e);
} catch (NoSuchFieldException e) {
Log.e(ActivityProcessor.ANDRIOD_TEST_RECORDER, "NoSuchFieldException", e);
}
final CompoundButton.OnCheckedChangeListener finalListener = listener;
checkable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
String id = activityProcessor.resolveId(buttonView.getId());
if (id != null) {
String descr = (isChecked ? "Check " : "Uncheck ") + activityProcessor.getWidgetName(buttonView) + " with id "+id;
|
activityProcessor.getEventWriter().writeEvent(new RecordingEvent(new com.vpedak.testsrecorder.core.events.View(id), new ClickAction(), descr));
|
vpedak/droidtestrec
|
RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
|
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
|
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
// Path: RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
|
RecordingEvent event1 = new RecordingEvent(new Data("adapterId", "className", "value"), new ClickAction(), "description text");
|
vpedak/droidtestrec
|
RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
|
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
|
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
// Path: RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
|
RecordingEvent event1 = new RecordingEvent(new Data("adapterId", "className", "value"), new ClickAction(), "description text");
|
vpedak/droidtestrec
|
RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
|
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
|
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
// Path: RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
|
RecordingEvent event1 = new RecordingEvent(new Data("adapterId", "className", "value"), new ClickAction(), "description text");
|
vpedak/droidtestrec
|
RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
|
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
|
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
RecordingEvent event1 = new RecordingEvent(new Data("adapterId", "className", "value"), new ClickAction(), "description text");
Assert.assertEquals("event=[,data=adapterId#className#value,action=click,description text]", event1.toString());
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
// public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
// generator.generateActon(sb, this, subject);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
// private String adapterId;
// private String className;
// private String value;
//
// public Data(String adapterId, String className) {
// this.adapterId = adapterId;
// this.className = className;
// }
// public Data(String adapterId, String className, String value) {
// this.adapterId = adapterId;
// this.className = className;
// this.value = value;
// }
//
// public String getAdapterId() {
// return adapterId;
// }
//
// public String getClassName() {
// return className;
// }
//
// public String getValue() {
// return value;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
// private String group = null;
// private Subject subject;
// private Action action;
// private String description;
// private long time;
//
// public RecordingEvent(String group, Subject subject, Action action) {
// this.group = group;
// this.subject = subject;
// this.action = action;
// }
//
// public RecordingEvent(Subject subject, Action action, String description) {
// this.subject = subject;
// this.action = action;
// this.description = description;
// }
//
// public Subject getSubject() {
// return subject;
// }
//
// public Action getAction() {
// return action;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public long getTime() {
// return time;
// }
//
// public void setTime(long time) {
// this.time = time;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateEvent(sb, this);
// }
//
// @Override
// public String toString() {
// return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
// (description==null?"":description)+"]";
// }
//
// public static RecordingEvent fromString(String str) {
// String tmp = str.substring(7, str.length()-1);
// String arr[] = tmp.split("[,]");
//
// String timeStr = arr[0];
// String group = arr[1];
// String subjectStr = arr[2];
// String actionStr = arr[3];
// String description = arr.length == 5 ? arr[4] : null;
// RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
//
// event.setTime(Long.parseLong(timeStr));
//
// if (group.length() > 0) {
// event.setGroup(group);
// }
//
// return event;
// }
// }
//
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
// private String id;
//
// public View(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public void accept(StringBuilder sb, TestGenerator generator){
// generator.generateSubject(sb, this);
// }
// }
// Path: RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
package com.vpedak.testrecorder.core.events;
public class RecordingEventTest {
@Test
public void testSerialization() {
RecordingEvent event1 = new RecordingEvent(new Data("adapterId", "className", "value"), new ClickAction(), "description text");
Assert.assertEquals("event=[,data=adapterId#className#value,action=click,description text]", event1.toString());
|
RecordingEvent event2 = new RecordingEvent(new View("viewId"), new ClickAction(), "description text");
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class View extends Subject {
private String id;
public View(String id) {
this.id = id;
}
public String getId() {
return id;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class View extends Subject {
private String id;
public View(String id) {
this.id = id;
}
public String getId() {
return id;
}
|
public void accept(StringBuilder sb, TestGenerator generator){
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/MenuItem.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
package com.vpedak.testsrecorder.core.events;
public class MenuItem extends Subject {
private CharSequence title;
private String id;
public MenuItem(CharSequence title, String id) {
this.title = title;
this.id = id;
}
public String getId() {
return id;
}
public CharSequence getTitle() {
return title;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/MenuItem.java
import com.vpedak.testsrecorder.core.TestGenerator;
package com.vpedak.testsrecorder.core.events;
public class MenuItem extends Subject {
private CharSequence title;
private String id;
public MenuItem(CharSequence title, String id) {
this.title = title;
this.id = id;
}
public String getId() {
return id;
}
public CharSequence getTitle() {
return title;
}
|
public void accept(StringBuilder sb, TestGenerator generator){
|
vpedak/droidtestrec
|
RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
|
import com.vpedak.testsrecorder.core.TestGenerator;
|
}
public Action getAction() {
return action;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
|
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/TestGenerator.java
// public interface TestGenerator {
// String generate(String activityClassName, String testClassName, String packageName, List<RecordingEvent> events);
//
// void generateEvent(StringBuilder sb, RecordingEvent event);
//
// void generateSubject(StringBuilder sb, Subject subject);
// void generateSubject(StringBuilder sb, View subject);
// void generateSubject(StringBuilder sb, DisplayedView subject);
// void generateSubject(StringBuilder sb, OptionsMenu subject);
// void generateSubject(StringBuilder sb, MenuItem subject);
// void generateSubject(StringBuilder sb, ParentView subject);
// void generateSubject(StringBuilder sb, ParentIdView subject);
// void generateSubject(StringBuilder sb, Data subject);
// void generateSubject(StringBuilder sb, Espresso subject);
//
// void generateActon(StringBuilder sb, Action action, Subject subject);
// void generateActon(StringBuilder sb, ClickAction action, Subject subject);
// void generateActon(StringBuilder sb, LongClickAction action, Subject subject);
// void generateActon(StringBuilder sb, ReplaceTextAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeUpAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeDownAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeLeftAction action, Subject subject);
// void generateActon(StringBuilder sb, SwipeRightAction action, Subject subject);
// void generateActon(StringBuilder sb, PressBackAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToPositionAction action, Subject subject);
// void generateActon(StringBuilder sb, SelectViewPagerPageAction action, Subject subject);
// void generateActon(StringBuilder sb, ScrollToAction action, Subject subject);
// }
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
import com.vpedak.testsrecorder.core.TestGenerator;
}
public Action getAction() {
return action;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
|
public void accept(StringBuilder sb, TestGenerator generator){
|
apigee/usergrid-android-sdk
|
src/main/java/org/usergrid/android/client/utils/DeviceUuidFactory.java
|
// Path: src/main/java/org/usergrid/android/client/utils/ObjectUtils.java
// public static boolean isEmpty(Object s) {
// if (s == null) {
// return true;
// }
// if ((s instanceof String) && (((String) s).trim().length() == 0)) {
// return true;
// }
// if (s instanceof Map) {
// return ((Map<?, ?>) s).isEmpty();
// }
// return false;
// }
|
import static org.usergrid.android.client.utils.ObjectUtils.isEmpty;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
|
}
private UUID generateDeviceUuid(Context context) {
// Get some of the hardware information
String buildParams = Build.BOARD + Build.BRAND + Build.CPU_ABI
+ Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST
+ Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT
+ Build.TAGS + Build.TYPE + Build.USER;
// Requires READ_PHONE_STATE
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
// gets the imei (GSM) or MEID/ESN (CDMA)
String imei = tm.getDeviceId();
// gets the android-assigned id
String androidId = Secure.getString(context.getContentResolver(),
Secure.ANDROID_ID);
// requires ACCESS_WIFI_STATE
WifiManager wm = (WifiManager) context
.getSystemService(Context.WIFI_SERVICE);
// gets the MAC address
String mac = wm.getConnectionInfo().getMacAddress();
// if we've got nothing, return a random UUID
|
// Path: src/main/java/org/usergrid/android/client/utils/ObjectUtils.java
// public static boolean isEmpty(Object s) {
// if (s == null) {
// return true;
// }
// if ((s instanceof String) && (((String) s).trim().length() == 0)) {
// return true;
// }
// if (s instanceof Map) {
// return ((Map<?, ?>) s).isEmpty();
// }
// return false;
// }
// Path: src/main/java/org/usergrid/android/client/utils/DeviceUuidFactory.java
import static org.usergrid.android.client.utils.ObjectUtils.isEmpty;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
}
private UUID generateDeviceUuid(Context context) {
// Get some of the hardware information
String buildParams = Build.BOARD + Build.BRAND + Build.CPU_ABI
+ Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST
+ Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT
+ Build.TAGS + Build.TYPE + Build.USER;
// Requires READ_PHONE_STATE
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
// gets the imei (GSM) or MEID/ESN (CDMA)
String imei = tm.getDeviceId();
// gets the android-assigned id
String androidId = Secure.getString(context.getContentResolver(),
Secure.ANDROID_ID);
// requires ACCESS_WIFI_STATE
WifiManager wm = (WifiManager) context
.getSystemService(Context.WIFI_SERVICE);
// gets the MAC address
String mac = wm.getConnectionInfo().getMacAddress();
// if we've got nothing, return a random UUID
|
if (isEmpty(imei) && isEmpty(androidId) && isEmpty(mac)) {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.