Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
1b7c4295
G
glide
项目概览
沉迷打码的小凳子
/
glide
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1b7c4295
编写于
5月 14, 2018
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove deprecated ExpectedException calls.
上级
d2d5c4e4
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
361 addition
and
257 deletion
+361
-257
annotation/compiler/test/build.gradle
annotation/compiler/test/build.gradle
+1
-0
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidAppGlideModuleWithExcludesTest.java
...ation/compiler/InvalidAppGlideModuleWithExcludesTest.java
+23
-19
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidGlideExtensionTest.java
.../glide/annotation/compiler/InvalidGlideExtensionTest.java
+1
-5
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidGlideOptionsExtensionTest.java
...annotation/compiler/InvalidGlideOptionsExtensionTest.java
+95
-72
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidGlideTypeExtensionTest.java
...de/annotation/compiler/InvalidGlideTypeExtensionTest.java
+118
-91
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleAppGlideModuleTest.java
...glide/annotation/compiler/MultipleAppGlideModuleTest.java
+12
-6
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleEmptyLibraryGlideModuleTest.java
...otation/compiler/MultipleEmptyLibraryGlideModuleTest.java
+0
-2
instrumentation/src/androidTest/java/com/bumptech/glide/CenterInsideRegressionTest.java
...t/java/com/bumptech/glide/CenterInsideRegressionTest.java
+0
-2
instrumentation/src/androidTest/java/com/bumptech/glide/CircleCropRegressionTest.java
...est/java/com/bumptech/glide/CircleCropRegressionTest.java
+0
-2
instrumentation/src/androidTest/java/com/bumptech/glide/DrawableTransformationTest.java
...t/java/com/bumptech/glide/DrawableTransformationTest.java
+17
-13
instrumentation/src/androidTest/java/com/bumptech/glide/FitCenterRegressionTest.java
...Test/java/com/bumptech/glide/FitCenterRegressionTest.java
+20
-13
instrumentation/src/androidTest/java/com/bumptech/glide/NonBitmapDrawableResourcesTest.java
...va/com/bumptech/glide/NonBitmapDrawableResourcesTest.java
+27
-14
library/test/src/test/java/com/bumptech/glide/load/engine/EngineKeyTest.java
...st/java/com/bumptech/glide/load/engine/EngineKeyTest.java
+12
-6
library/test/src/test/java/com/bumptech/glide/load/model/MultiModelLoaderFactoryTest.java
...umptech/glide/load/model/MultiModelLoaderFactoryTest.java
+35
-12
未找到文件。
annotation/compiler/test/build.gradle
浏览文件 @
1b7c4295
...
...
@@ -13,6 +13,7 @@ dependencies {
// build.gradle file.
testImplementation
project
(
':glide'
)
testImplementation
project
(
':annotation:compiler'
)
testImplementation
"junit:junit:${JUNIT_VERSION}"
testImplementation
"com.squareup:javapoet:${JAVAPOET_VERSION}"
testImplementation
"com.google.auto.service:auto-service:${AUTO_SERVICE_VERSION}"
testImplementation
"com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
...
...
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidAppGlideModuleWithExcludesTest.java
浏览文件 @
1b7c4295
...
...
@@ -2,40 +2,44 @@ package com.bumptech.glide.annotation.compiler;
import
static
com
.
google
.
testing
.
compile
.
CompilationSubject
.
assertThat
;
import
static
com
.
google
.
testing
.
compile
.
Compiler
.
javac
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
com.google.testing.compile.Compilation
;
import
com.google.testing.compile.JavaFileObjects
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
/**
* Tests AppGlideModules with invalid usages of the @Excludes annotation.
*/
// Ignore warnings since most methods use
ExpectedException
// Ignore warnings since most methods use
assertThrows
@SuppressWarnings
(
"ResultOfMethodCallIgnored"
)
@RunWith
(
JUnit4
.
class
)
public
class
InvalidAppGlideModuleWithExcludesTest
{
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Test
public
void
compilation_withMissingExcludedModuleClass_throws
()
{
expectedException
.
expect
(
RuntimeException
.
class
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
JavaFileObjects
.
forSourceLines
(
"AppModuleWithExcludes"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.Excludes;"
,
"import com.bumptech.glide.annotation.GlideModule;"
,
"import com.bumptech.glide.module.AppGlideModule;"
,
"import com.bumptech.glide.test.EmptyLibraryModule;"
,
"@GlideModule"
,
"@Excludes(EmptyLibraryModule.class)"
,
"public final class AppModuleWithExcludes extends AppGlideModule {}"
));
assertThrows
(
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
JavaFileObjects
.
forSourceLines
(
"AppModuleWithExcludes"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.Excludes;"
,
"import com.bumptech.glide.annotation.GlideModule;"
,
"import com.bumptech.glide.module.AppGlideModule;"
,
"import com.bumptech.glide.test.EmptyLibraryModule;"
,
"@GlideModule"
,
"@Excludes(EmptyLibraryModule.class)"
,
"public final class AppModuleWithExcludes extends AppGlideModule {}"
));
}
});
}
@Test
...
...
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidGlideExtensionTest.java
浏览文件 @
1b7c4295
...
...
@@ -8,21 +8,17 @@ import static org.junit.Assert.fail;
import
com.google.common.truth.Truth
;
import
com.google.testing.compile.Compilation
;
import
com.google.testing.compile.JavaFileObjects
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
/**
* Checks assertions on {@link com.bumptech.glide.annotation.GlideExtension}s themselves.
*/
// Avoid warnings when
using ExpectedException
.
// Avoid warnings when
asserting on exceptions
.
@SuppressWarnings
(
"ResultOfMethodCallIgnored"
)
@RunWith
(
JUnit4
.
class
)
public
class
InvalidGlideExtensionTest
{
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Test
public
void
compilation_withPublicConstructor_fails
()
{
try
{
...
...
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidGlideOptionsExtensionTest.java
浏览文件 @
1b7c4295
...
...
@@ -3,14 +3,14 @@ package com.bumptech.glide.annotation.compiler;
import
static
com
.
bumptech
.
glide
.
annotation
.
compiler
.
test
.
Util
.
emptyAppModule
;
import
static
com
.
google
.
testing
.
compile
.
CompilationSubject
.
assertThat
;
import
static
com
.
google
.
testing
.
compile
.
Compiler
.
javac
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
junit
.
Assert
.
fail
;
import
com.google.common.truth.Truth
;
import
com.google.testing.compile.Compilation
;
import
com.google.testing.compile.JavaFileObjects
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
...
...
@@ -18,30 +18,34 @@ import org.junit.runners.JUnit4;
* Checks assertions on {@link com.bumptech.glide.annotation.GlideExtension}s for methods annotated
* with {@link com.bumptech.glide.annotation.GlideOption}.
*/
// Ignore warnings since most methods use
ExpectedException
// Ignore warnings since most methods use
assertThrows.
@SuppressWarnings
(
"ResultOfMethodCallIgnored"
)
@RunWith
(
JUnit4
.
class
)
public
class
InvalidGlideOptionsExtensionTest
{
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Test
public
void
compilation_withAnnotatedNonStaticMethod_fails
()
{
expectedException
.
expect
(
RuntimeException
.
class
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption"
,
" public void doSomething() {}"
,
"}"
));
assertThrows
(
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption"
,
" public void doSomething() {}"
,
"}"
));
}
});
}
@Test
...
...
@@ -118,44 +122,57 @@ public class InvalidGlideOptionsExtensionTest {
@Test
public
void
compilation_overridingOptionWithoutAnnotationType_fails
()
{
expectedException
.
expect
(
RuntimeException
.
class
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"import com.bumptech.glide.request.RequestOptions;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption"
,
" public static void centerCrop(RequestOptions options) {}"
,
"}"
));
assertThrows
(
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"import com.bumptech.glide.request.RequestOptions;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption"
,
" public static void centerCrop(RequestOptions options) {}"
,
"}"
));
}
});
}
@Test
public
void
compilation_withOverrideExtend_butNotOverridingMethod_fails
()
{
expectedException
.
expect
(
RuntimeException
.
class
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"import com.bumptech.glide.request.RequestOptions;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption(override = GlideOption.OVERRIDE_EXTEND)"
,
" public static void something(RequestOptions options) {}"
,
"}"
));
assertThrows
(
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"import com.bumptech.glide.request.RequestOptions;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption(override = GlideOption.OVERRIDE_EXTEND)"
,
" public static void something(RequestOptions options) {}"
,
"}"
));
}
});
}
@Test
...
...
@@ -182,23 +199,29 @@ public class InvalidGlideOptionsExtensionTest {
@Test
public
void
compilation_withOverrideReplace_butNotOverridingMethod_fails
()
{
expectedException
.
expect
(
RuntimeException
.
class
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"import com.bumptech.glide.request.RequestOptions;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption(override = GlideOption.OVERRIDE_REPLACE)"
,
" public static void something(RequestOptions options) {}"
,
"}"
));
assertThrows
(
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideOption;"
,
"import com.bumptech.glide.request.RequestOptions;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideOption(override = GlideOption.OVERRIDE_REPLACE)"
,
" public static void something(RequestOptions options) {}"
,
"}"
));
}
});
}
@Test
...
...
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/InvalidGlideTypeExtensionTest.java
浏览文件 @
1b7c4295
...
...
@@ -5,15 +5,15 @@ import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule;
import
static
com
.
bumptech
.
glide
.
annotation
.
compiler
.
test
.
Util
.
subpackage
;
import
static
com
.
google
.
testing
.
compile
.
CompilationSubject
.
assertThat
;
import
static
com
.
google
.
testing
.
compile
.
Compiler
.
javac
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
junit
.
Assert
.
fail
;
import
com.google.common.truth.Truth
;
import
com.google.testing.compile.Compilation
;
import
com.google.testing.compile.JavaFileObjects
;
import
java.io.IOException
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
...
...
@@ -21,54 +21,64 @@ import org.junit.runners.JUnit4;
* Checks assertions on {@link com.bumptech.glide.annotation.GlideExtension}s for methods annotated
* with {@link com.bumptech.glide.annotation.GlideType}.
*/
// Ignore warnings since most methods use
ExpectedException
// Ignore warnings since most methods use
assertThrows.
@SuppressWarnings
(
"ResultOfMethodCallIgnored"
)
@RunWith
(
JUnit4
.
class
)
public
class
InvalidGlideTypeExtensionTest
{
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Test
public
void
compilation_withAnnotatedNonStaticMethod_fails
()
{
expectedException
.
expectMessage
(
"@GlideType methods must be static"
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public void doSomething() {}"
,
"}"
));
assertThrows
(
"@GlideType methods must be static"
,
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public void doSomething() {}"
,
"}"
));
}
});
}
@Test
public
void
compilation_withAnnotatedStaticMethod_withoutRequestBuilderArg_fails
()
{
expectedException
.
expectMessage
(
"@GlideType methods must take a RequestBuilder object as their first and only"
+
" parameter, but given multiple for:"
+
" com.bumptech.glide.test.Extension#doSomething()"
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public static void doSomething() {}"
,
"}"
));
assertThrows
(
"@GlideType methods must take a RequestBuilder object as their first and only"
+
" parameter, but given multiple for:"
+
" com.bumptech.glide.test.Extension#doSomething()"
,
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public static void doSomething() {}"
,
"}"
));
}
});
}
@Test
...
...
@@ -121,35 +131,40 @@ public class InvalidGlideTypeExtensionTest {
@Test
public
void
compilation_withAnnotatedStaticMethod_withRequestBuilderArgAndOtherArg_fails
()
{
expectedException
.
expectMessage
(
"@GlideType methods must take a RequestBuilder object as their first and only"
+
" parameter, but given multiple for:"
+
" com.bumptech.glide.test.Extension#type("
+
"com.bumptech.glide.RequestBuilder<java.lang.Number>,"
+
"java.lang.Object)"
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.RequestBuilder;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public static void type(RequestBuilder<Number> builder, Object arg2) {}"
,
"}"
));
assertThrows
(
"@GlideType methods must take a RequestBuilder object as their first and only"
+
" parameter, but given multiple for:"
+
" com.bumptech.glide.test.Extension#type("
+
"com.bumptech.glide.RequestBuilder<java.lang.Number>,"
+
"java.lang.Object)"
,
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.RequestBuilder;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public static void type(RequestBuilder<Number> builder, Object arg2) {}"
,
"}"
));
}
});
}
@Test
public
void
compilation_withAnnotatedStaticMethod_overridingExistingType_fails
()
throws
IOException
{
Compilation
compilation
=
final
Compilation
compilation
=
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
...
...
@@ -167,11 +182,17 @@ public class InvalidGlideTypeExtensionTest {
" @GlideType(Drawable.class)"
,
" public static void asDrawable(RequestBuilder<Drawable> builder) {}"
,
"}"
));
expectedException
.
expectMessage
(
"error: method asDrawable() is already defined in class"
+
" com.bumptech.glide.test.GlideRequests"
);
compilation
.
generatedSourceFile
(
subpackage
(
"GlideRequests"
));
assertThrows
(
"error: method asDrawable() is already defined in class"
+
" com.bumptech.glide.test.GlideRequests"
,
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
compilation
.
generatedSourceFile
(
subpackage
(
"GlideRequests"
));
}
});
}
@Test
...
...
@@ -266,30 +287,36 @@ public class InvalidGlideTypeExtensionTest {
@Test
public
void
compilation_withAnnotatedStaticMethod_returningBuilder_andMultipleParams_fails
()
{
expectedException
.
expectMessage
(
assertThrows
(
"@GlideType methods must take a RequestBuilder object as their first and only parameter,"
+
" but given multiple for:"
+
" com.bumptech.glide.test.Extension#asNumber("
+
"com.bumptech.glide.RequestBuilder<java.lang.Number>,java.lang.Object)"
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.RequestBuilder;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public static RequestBuilder<Number> asNumber("
,
" RequestBuilder<Number> builder, Object arg1) {"
,
" return builder;"
,
" }"
,
"}"
));
+
"com.bumptech.glide.RequestBuilder<java.lang.Number>,java.lang.Object)"
,
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
emptyAppModule
(),
JavaFileObjects
.
forSourceLines
(
"Extension"
,
"package com.bumptech.glide.test;"
,
"import com.bumptech.glide.RequestBuilder;"
,
"import com.bumptech.glide.annotation.GlideExtension;"
,
"import com.bumptech.glide.annotation.GlideType;"
,
"@GlideExtension"
,
"public class Extension {"
,
" private Extension() {}"
,
" @GlideType(Number.class)"
,
" public static RequestBuilder<Number> asNumber("
,
" RequestBuilder<Number> builder, Object arg1) {"
,
" return builder;"
,
" }"
,
"}"
));
}
});
}
@Test
...
...
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleAppGlideModuleTest.java
浏览文件 @
1b7c4295
...
...
@@ -2,6 +2,7 @@ package com.bumptech.glide.annotation.compiler;
import
static
com
.
google
.
testing
.
compile
.
CompilationSubject
.
assertThat
;
import
static
com
.
google
.
testing
.
compile
.
Compiler
.
javac
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
com.bumptech.glide.annotation.compiler.test.RegenerateResourcesRule
;
import
com.bumptech.glide.annotation.compiler.test.Util
;
...
...
@@ -9,7 +10,7 @@ import com.google.testing.compile.Compilation;
import
javax.tools.JavaFileObject
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
...
...
@@ -23,16 +24,21 @@ public class MultipleAppGlideModuleTest {
private
static
final
String
SECOND_MODULE
=
"EmptyAppModule2.java"
;
@Rule
public
final
RegenerateResourcesRule
regenerateResourcesRule
=
new
RegenerateResourcesRule
(
getClass
());
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
// Throws.
@SuppressWarnings
(
"ResultOfMethodCallIgnored"
)
@Test
public
void
compilation_withTwoAppModules_fails
()
{
expectedException
.
expect
(
RuntimeException
.
class
);
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
forResource
(
FIRST_MODULE
),
forResource
(
SECOND_MODULE
));
assertThrows
(
RuntimeException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
javac
()
.
withProcessors
(
new
GlideAnnotationProcessor
())
.
compile
(
forResource
(
FIRST_MODULE
),
forResource
(
SECOND_MODULE
));
}
});
}
@Test
...
...
annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleEmptyLibraryGlideModuleTest.java
浏览文件 @
1b7c4295
...
...
@@ -14,7 +14,6 @@ import javax.tools.JavaFileObject;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
...
...
@@ -25,7 +24,6 @@ import org.junit.runners.JUnit4;
public
class
MultipleEmptyLibraryGlideModuleTest
{
@Rule
public
final
RegenerateResourcesRule
regenerateResourcesRule
=
new
RegenerateResourcesRule
(
getClass
());
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
private
Compilation
compilation
;
@Before
...
...
instrumentation/src/androidTest/java/com/bumptech/glide/CenterInsideRegressionTest.java
浏览文件 @
1b7c4295
...
...
@@ -17,7 +17,6 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.TestName
;
import
org.junit.runner.RunWith
;
...
...
@@ -27,7 +26,6 @@ import org.junit.runner.RunWith;
@RegressionTest
public
class
CenterInsideRegressionTest
{
@Rule
public
final
TestName
testName
=
new
TestName
();
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Rule
public
final
TearDownGlide
tearDownGlide
=
new
TearDownGlide
();
private
BitmapRegressionTester
bitmapRegressionTester
;
private
Context
context
;
...
...
instrumentation/src/androidTest/java/com/bumptech/glide/CircleCropRegressionTest.java
浏览文件 @
1b7c4295
...
...
@@ -17,7 +17,6 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.TestName
;
import
org.junit.runner.RunWith
;
...
...
@@ -27,7 +26,6 @@ import org.junit.runner.RunWith;
@RegressionTest
public
class
CircleCropRegressionTest
{
@Rule
public
final
TestName
testName
=
new
TestName
();
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Rule
public
final
TearDownGlide
tearDownGlide
=
new
TearDownGlide
();
private
BitmapRegressionTester
bitmapRegressionTester
;
private
Context
context
;
...
...
instrumentation/src/androidTest/java/com/bumptech/glide/DrawableTransformationTest.java
浏览文件 @
1b7c4295
package
com.bumptech.glide
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
...
@@ -22,15 +23,12 @@ import com.bumptech.glide.test.GlideApp;
import
java.util.concurrent.ExecutionException
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.runner.RunWith
;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
DrawableTransformationTest
{
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
private
Context
context
;
@Before
...
...
@@ -117,15 +115,21 @@ public class DrawableTransformationTest {
@Test
public
void
load_withColorDrawable_sizeOriginal_requiredTransform_fails
()
throws
ExecutionException
,
InterruptedException
{
Drawable
colorDrawable
=
new
ColorDrawable
(
Color
.
RED
);
expectedException
.
expect
(
ExecutionException
.
class
);
Glide
.
with
(
context
)
.
load
(
colorDrawable
)
.
apply
(
new
RequestOptions
()
.
centerCrop
())
.
submit
()
.
get
();
final
Drawable
colorDrawable
=
new
ColorDrawable
(
Color
.
RED
);
assertThrows
(
ExecutionException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
Glide
.
with
(
context
)
.
load
(
colorDrawable
)
.
apply
(
new
RequestOptions
()
.
centerCrop
())
.
submit
()
.
get
();
}
});
}
@Test
...
...
instrumentation/src/androidTest/java/com/bumptech/glide/FitCenterRegressionTest.java
浏览文件 @
1b7c4295
package
com.bumptech.glide
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
...
...
@@ -17,7 +18,7 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.rules.TestName
;
import
org.junit.runner.RunWith
;
...
...
@@ -27,7 +28,6 @@ import org.junit.runner.RunWith;
@RegressionTest
public
class
FitCenterRegressionTest
{
@Rule
public
final
TestName
testName
=
new
TestName
();
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Rule
public
final
TearDownGlide
tearDownGlide
=
new
TearDownGlide
();
private
BitmapRegressionTester
bitmapRegressionTester
;
private
Context
context
;
...
...
@@ -108,16 +108,23 @@ public class FitCenterRegressionTest {
public
void
fitCenter_withHugeRectangle_throwsOOM
()
throws
ExecutionException
,
InterruptedException
{
float
multiplier
=
Integer
.
MAX_VALUE
/
(
canonical
.
getWidth
()
*
canonical
.
getHeight
()
*
2
);
int
overrideWidth
=
(
int
)
multiplier
*
canonical
.
getWidth
();
int
overrideHeight
=
(
int
)
multiplier
*
canonical
.
getHeight
();
expectedException
.
expect
(
ExecutionException
.
class
);
GlideApp
.
with
(
context
)
.
asBitmap
()
.
load
(
canonical
.
getBitmap
())
.
fitCenter
()
.
override
(
overrideWidth
,
overrideHeight
)
.
submit
()
.
get
();
final
int
overrideWidth
=
(
int
)
multiplier
*
canonical
.
getWidth
();
final
int
overrideHeight
=
(
int
)
multiplier
*
canonical
.
getHeight
();
assertThrows
(
ExecutionException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
GlideApp
.
with
(
context
)
.
asBitmap
()
.
load
(
canonical
.
getBitmap
())
.
fitCenter
()
.
override
(
overrideWidth
,
overrideHeight
)
.
submit
()
.
get
();
}
});
}
}
instrumentation/src/androidTest/java/com/bumptech/glide/NonBitmapDrawableResourcesTest.java
浏览文件 @
1b7c4295
...
...
@@ -3,6 +3,7 @@ package com.bumptech.glide;
import
static
com
.
bumptech
.
glide
.
request
.
RequestOptions
.
bitmapTransform
;
import
static
com
.
bumptech
.
glide
.
request
.
RequestOptions
.
centerCropTransform
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
android.content.ContentResolver
;
import
android.content.Context
;
...
...
@@ -27,7 +28,7 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.rules.TestName
;
import
org.junit.runner.RunWith
;
import
org.mockito.MockitoAnnotations
;
...
...
@@ -36,7 +37,6 @@ import org.mockito.MockitoAnnotations;
public
class
NonBitmapDrawableResourcesTest
{
@Rule
public
final
TestName
testName
=
new
TestName
();
@Rule
public
final
TearDownGlide
tearDownGlide
=
new
TearDownGlide
();
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
private
Context
context
;
...
...
@@ -123,12 +123,19 @@ public class NonBitmapDrawableResourcesTest {
@Test
public
void
load_withShapeDrawableResourceId_asDrawable_withTransformation_sizeOriginal_fails
()
throws
ExecutionException
,
InterruptedException
{
expectedException
.
expect
(
ExecutionException
.
class
);
Glide
.
with
(
context
)
.
load
(
ResourceIds
.
drawable
.
shape_drawable
)
.
apply
(
centerCropTransform
())
.
submit
()
.
get
();
assertThrows
(
ExecutionException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
Glide
.
with
(
context
)
.
load
(
ResourceIds
.
drawable
.
shape_drawable
)
.
apply
(
centerCropTransform
())
.
submit
()
.
get
();
}
});
}
@Test
...
...
@@ -147,12 +154,18 @@ public class NonBitmapDrawableResourcesTest {
@Test
public
void
load_withShapeDrawableResourceId_asBitmap_withSizeOriginal_fails
()
throws
ExecutionException
,
InterruptedException
{
expectedException
.
expect
(
ExecutionException
.
class
);
Glide
.
with
(
context
)
.
asBitmap
()
.
load
(
ResourceIds
.
drawable
.
shape_drawable
)
.
submit
()
.
get
();
assertThrows
(
ExecutionException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
Glide
.
with
(
context
)
.
asBitmap
()
.
load
(
ResourceIds
.
drawable
.
shape_drawable
)
.
submit
()
.
get
();
}
});
}
@Test
...
...
library/test/src/test/java/com/bumptech/glide/load/engine/EngineKeyTest.java
浏览文件 @
1b7c4295
package
com.bumptech.glide.load.engine
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
android.support.annotation.NonNull
;
import
com.bumptech.glide.load.Key
;
import
com.bumptech.glide.load.Option
;
...
...
@@ -12,9 +14,8 @@ import java.security.MessageDigest;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Collections
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
...
...
@@ -24,7 +25,6 @@ import org.robolectric.annotation.Config;
@RunWith
(
RobolectricTestRunner
.
class
)
@Config
(
manifest
=
Config
.
NONE
,
sdk
=
18
)
public
class
EngineKeyTest
{
@Rule
public
final
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Mock
private
Transformation
<
Object
>
transformation
;
@Before
...
...
@@ -35,7 +35,7 @@ public class EngineKeyTest {
@Test
public
void
updateDiskCacheKey_throwsException
()
throws
NoSuchAlgorithmException
{
// If this test fails, update testEqualsAndHashcode to use KeyTester including regression tests.
EngineKey
key
=
new
EngineKey
(
final
EngineKey
key
=
new
EngineKey
(
"id"
,
new
ObjectKey
(
"signature"
),
100
,
...
...
@@ -44,8 +44,14 @@ public class EngineKeyTest {
Object
.
class
,
Object
.
class
,
new
Options
());
expectedException
.
expect
(
UnsupportedOperationException
.
class
);
key
.
updateDiskCacheKey
(
MessageDigest
.
getInstance
(
"SHA-1"
));
assertThrows
(
UnsupportedOperationException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
NoSuchAlgorithmException
{
key
.
updateDiskCacheKey
(
MessageDigest
.
getInstance
(
"SHA-1"
));
}
});
}
@Test
...
...
library/test/src/test/java/com/bumptech/glide/load/model/MultiModelLoaderFactoryTest.java
浏览文件 @
1b7c4295
package
com.bumptech.glide.load.model
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
...
...
@@ -13,9 +14,8 @@ import com.bumptech.glide.util.pool.FactoryPools;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.
rules.ExpectedException
;
import
org.junit.
function.ThrowingRunnable
;
import
org.junit.runner.RunWith
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Mock
;
...
...
@@ -28,8 +28,6 @@ import org.robolectric.annotation.Config;
@RunWith
(
RobolectricTestRunner
.
class
)
@Config
(
manifest
=
Config
.
NONE
,
sdk
=
18
)
public
class
MultiModelLoaderFactoryTest
{
@Rule
public
final
ExpectedException
exception
=
ExpectedException
.
none
();
@Mock
private
ModelLoaderFactory
<
String
,
String
>
firstFactory
;
@Mock
private
ModelLoader
<
String
,
String
>
firstModelLoader
;
@Mock
private
MultiModelLoaderFactory
.
Factory
multiModelLoaderFactory
;
...
...
@@ -183,16 +181,28 @@ public class MultiModelLoaderFactoryTest {
public
void
testBuild_withModelAndDataClasses_excludesModelLoadersForOtherDataClasses
()
{
multiFactory
.
append
(
String
.
class
,
String
.
class
,
firstFactory
);
exception
.
expect
(
NoModelLoaderAvailableException
.
class
);
multiFactory
.
build
(
String
.
class
,
Integer
.
class
);
assertThrows
(
NoModelLoaderAvailableException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
multiFactory
.
build
(
String
.
class
,
Integer
.
class
);
}
});
}
@Test
public
void
testBuild_withModelAndDataClasses_excludesModelLoadersForOtherModelClasses
()
{
multiFactory
.
append
(
String
.
class
,
String
.
class
,
firstFactory
);
exception
.
expect
(
NoModelLoaderAvailableException
.
class
);
multiFactory
.
build
(
Integer
.
class
,
String
.
class
);
assertThrows
(
NoModelLoaderAvailableException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
multiFactory
.
build
(
Integer
.
class
,
String
.
class
);
}
});
}
@Test
...
...
@@ -212,15 +222,28 @@ public class MultiModelLoaderFactoryTest {
@Test
public
void
testBuild_withModelAndDataClass_doesNotMatchSubclassesOfModelClass
()
{
appendFactoryFor
(
String
.
class
,
Object
.
class
);
exception
.
expect
(
NoModelLoaderAvailableException
.
class
);
multiFactory
.
build
(
Object
.
class
,
Object
.
class
);
assertThrows
(
NoModelLoaderAvailableException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
multiFactory
.
build
(
Object
.
class
,
Object
.
class
);
}
});
}
@Test
public
void
testBuild_withModelAndDataClass_doesNotMatchSubclassesOfDataClass
()
{
appendFactoryFor
(
Object
.
class
,
String
.
class
);
exception
.
expect
(
NoModelLoaderAvailableException
.
class
);
multiFactory
.
build
(
Object
.
class
,
Object
.
class
);
assertThrows
(
NoModelLoaderAvailableException
.
class
,
new
ThrowingRunnable
()
{
@Override
public
void
run
()
throws
Throwable
{
multiFactory
.
build
(
Object
.
class
,
Object
.
class
);
}
});
}
@Test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录