Project renaming

This commit is contained in:
George Mount
2015-01-27 10:58:49 -08:00
parent 066651563a
commit 860a2fc4aa
48 changed files with 334 additions and 13 deletions

View File

@@ -37,7 +37,7 @@ sourceSets {
}
dependencies {
compile project(":annotations")
compile project(":baseLibrary")
compile project(":compiler")
}

View File

@@ -41,7 +41,7 @@ uploadArchives {
mavenDeployer {
repository(url: mavenLocal().url)
pom.version = '0.3-SNAPSHOT'
pom.artifactId = 'annotations'
pom.artifactId = 'baseLibrary'
pom.groupId='com.android.databinding'
}
}

View File

@@ -35,9 +35,9 @@ dependencies {
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'com.google.guava:guava:18.0'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile project(":annotations")
compile project(":grammerBuilder")
compile project(":xmlGrammer")
compile project(":baseLibrary")
compile project(":grammarBuilder")
compile project(":xmlGrammar")
}
uploadArchives {
repositories {

View File

@@ -48,7 +48,7 @@ uploadArchives {
repositories {
mavenDeployer {
repository(url: mavenLocal().url)
pom.artifactId = 'grammerBuilder'
pom.artifactId = 'grammarBuilder'
}
}
}

View File

@@ -31,6 +31,7 @@ buildscript {
apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
compileSdkVersion 21
buildToolsVersion "21.1"
@@ -52,10 +53,16 @@ android {
}
}
}
sourceSets {
test {
java {
srcDir 'src/test/java'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":annotations")
compile project(":baseLibrary")
provided 'com.android.support:cardview-v7:+'
provided 'com.android.support:appcompat-v7:+'
provided project(":annotationprocessor")

View File

@@ -0,0 +1,314 @@
/*
* Copyright (C) 2014 The Android 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.
*/
package com.android.databinding.library;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.ArrayList;
public class CallbackRegistryTest {
final Integer callback1 = 1;
final Integer callback2 = 2;
final Integer callback3 = 3;
CallbackRegistry<Integer, CallbackRegistryTest, Integer> registry;
int notify1;
int notify2;
int notify3;
int[] deepNotifyCount = new int[300];
Integer argValue;
private void addNotifyCount(Integer callback) {
if (callback == callback1) {
notify1++;
} else if (callback == callback2) {
notify2++;
} else if (callback == callback3) {
notify3++;
}
deepNotifyCount[callback]++;
}
@Test
public void testAddListener() {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg, Integer arg2) {
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
Integer callback = 0;
assertNotNull(registry.copyListeners());
assertEquals(0, registry.copyListeners().size());
registry.add(callback);
ArrayList<Integer> callbacks = registry.copyListeners();
assertEquals(1, callbacks.size());
assertEquals(callback, callbacks.get(0));
registry.add(callback);
callbacks = registry.copyListeners();
assertEquals(1, callbacks.size());
assertEquals(callback, callbacks.get(0));
Integer otherListener = 1;
registry.add(otherListener);
callbacks = registry.copyListeners();
assertEquals(2, callbacks.size());
assertEquals(callback, callbacks.get(0));
assertEquals(otherListener, callbacks.get(1));
registry.remove(callback);
registry.add(callback);
callbacks = registry.copyListeners();
assertEquals(2, callbacks.size());
assertEquals(callback, callbacks.get(1));
assertEquals(otherListener, callbacks.get(0));
}
@Test
public void testSimpleNotify() {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
assertEquals(arg1, (int) arg);
addNotifyCount(callback);
argValue = arg;
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
registry.add(callback2);
Integer arg = 1;
registry.notifyCallbacks(this, arg, arg);
assertEquals(arg, argValue);
assertEquals(1, notify2);
}
@Test
public void testRemoveWhileNotifying() {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
if (callback == callback1) {
registry.remove(callback1);
registry.remove(callback2);
}
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
registry.add(callback1);
registry.add(callback2);
registry.add(callback3);
registry.notifyCallbacks(this, 0, null);
assertEquals(1, notify1);
assertEquals(1, notify2);
assertEquals(1, notify3);
ArrayList<Integer> callbacks = registry.copyListeners();
assertEquals(1, callbacks.size());
assertEquals(callback3, callbacks.get(0));
}
@Test
public void testDeepRemoveWhileNotifying() {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
registry.remove(callback);
registry.notifyCallbacks(CallbackRegistryTest.this, arg1, null);
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
registry.add(callback1);
registry.add(callback2);
registry.add(callback3);
registry.notifyCallbacks(this, 0, null);
assertEquals(1, notify1);
assertEquals(2, notify2);
assertEquals(3, notify3);
ArrayList<Integer> callbacks = registry.copyListeners();
assertEquals(0, callbacks.size());
}
@Test
public void testAddRemovedListener() {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
if (callback == callback1) {
registry.remove(callback2);
} else if (callback == callback3) {
registry.add(callback2);
}
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
registry.add(callback1);
registry.add(callback2);
registry.add(callback3);
registry.notifyCallbacks(this, 0, null);
ArrayList<Integer> callbacks = registry.copyListeners();
assertEquals(3, callbacks.size());
assertEquals(callback1, callbacks.get(0));
assertEquals(callback3, callbacks.get(1));
assertEquals(callback2, callbacks.get(2));
assertEquals(1, notify1);
assertEquals(1, notify2);
assertEquals(1, notify3);
}
@Test
public void testVeryDeepRemoveWhileNotifying() {
final Integer[] callbacks = new Integer[deepNotifyCount.length];
for (int i = 0; i < callbacks.length; i++) {
callbacks[i] = i;
}
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
registry.remove(callback);
registry.remove(callbacks[callbacks.length - callback - 1]);
registry.notifyCallbacks(CallbackRegistryTest.this, arg1, null);
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
for (int i = 0; i < callbacks.length; i++) {
registry.add(callbacks[i]);
}
registry.notifyCallbacks(this, 0, null);
for (int i = 0; i < deepNotifyCount.length; i++) {
int expectedCount = Math.min(i + 1, deepNotifyCount.length - i);
assertEquals(expectedCount, deepNotifyCount[i]);
}
ArrayList<Integer> callbackList = registry.copyListeners();
assertEquals(0, callbackList.size());
}
@Test
public void testClear() {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
for (int i = 0; i < deepNotifyCount.length; i++) {
registry.add(i);
}
registry.clear();
ArrayList<Integer> callbackList = registry.copyListeners();
assertEquals(0, callbackList.size());
registry.notifyCallbacks(this, 0, null);
for (int i = 0; i < deepNotifyCount.length; i++) {
assertEquals(0, deepNotifyCount[i]);
}
}
@Test
public void testNestedClear() {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
registry.clear();
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
for (int i = 0; i < deepNotifyCount.length; i++) {
registry.add(i);
}
registry.notifyCallbacks(this, 0, null);
for (int i = 0; i < deepNotifyCount.length; i++) {
assertEquals(1, deepNotifyCount[i]);
}
ArrayList<Integer> callbackList = registry.copyListeners();
assertEquals(0, callbackList.size());
}
@Test
public void testIsEmpty() throws Exception {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg, Integer arg2) {
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
Integer callback = 0;
assertTrue(registry.isEmpty());
registry.add(callback);
assertFalse(registry.isEmpty());
}
@Test
public void testClone() throws Exception {
CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer> notifier =
new CallbackRegistry.NotifierCallback<Integer, CallbackRegistryTest, Integer>() {
@Override
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg, Integer arg2) {
}
};
registry = new CallbackRegistry<Integer, CallbackRegistryTest, Integer>(notifier);
assertTrue(registry.isEmpty());
CallbackRegistry<Integer, CallbackRegistryTest, Integer> registry2 = registry.clone();
Integer callback = 0;
registry.add(callback);
assertFalse(registry.isEmpty());
assertTrue(registry2.isEmpty());
registry2 = registry.clone();
assertFalse(registry2.isEmpty());
}
}

View File

@@ -59,7 +59,7 @@ dependencies {
compile 'com.android.support:recyclerview-v7:21.0.2'
compile 'com.android.support:gridlayout-v7:21.+'
compile 'com.android.support:cardview-v7:21.+'
compile 'com.android.databinding:annotations:0.3-SNAPSHOT'
compile 'com.android.databinding:baseLibrary:0.3-SNAPSHOT'
//provided 'com.android.databinding:compiler:0.3-SNAPSHOT'
provided 'com.android.databinding:annotationprocessor:0.3-SNAPSHOT'
provided fileTree(dir : 'build/databinder/src', include : ['*.java'])

View File

@@ -1,8 +1,8 @@
include ':library'
include ':library', ':baseLibrary'
include ':compiler'
include ':gradlePlugin'
include ':annotations'
include ':grammerBuilder'
include ':baseLibrary'
include ':grammarBuilder'
include ':annotationprocessor'
include ':xmlGrammer'
include ':xmlGrammar'
include ':TestApp'