Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68fc89c

Browse files
committed
增加测试内存泄露的example
1 parent 5f692a9 commit 68fc89c

File tree

32 files changed

+518
-2
lines changed

32 files changed

+518
-2
lines changed
56 Bytes
Binary file not shown.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app', ':audiorecoder', ':mybinder', ':intentserviceexample',':wifi', ':testfiledownloader', ':testfiledownloader', ':mywindowmanager', ':myhook', ':myanimation', ':mybreakpointdownload', ':mygradletask', ':myndk', ':myclassloader', ':myinstrument', ':myreplugin', ':mywebview', ':myviewmodel', ':myroom', ':teststring', ':mylock', ':testjvm', ':testkotlin2', ':mylifecircle', ':testlifecircel', ':testleakcanary', ':testlock',':myndk_invoke',':myjni'
1+
include ':app', ':audiorecoder', ':mybinder', ':intentserviceexample',':wifi', ':testfiledownloader', ':testfiledownloader', ':mywindowmanager', ':myhook', ':myanimation', ':mybreakpointdownload', ':mygradletask', ':myndk', ':myclassloader', ':myinstrument', ':myreplugin', ':mywebview', ':myviewmodel', ':myroom', ':teststring', ':mylock', ':testjvm', ':testkotlin2', ':mylifecircle', ':testlifecircel', ':testleakcanary', ':testlock',':myndk_invoke',':myjni', ':testmemorylink'

testmemorylink/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

testmemorylink/build.gradle

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 27
5+
6+
7+
8+
defaultConfig {
9+
applicationId "com.example.testmemorylink"
10+
minSdkVersion 15
11+
targetSdkVersion 27
12+
versionCode 1
13+
versionName "1.0"
14+
15+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16+
17+
signingConfigs {
18+
release {
19+
keyAlias 'androiddebugkey'
20+
keyPassword 'android'
21+
storeFile file('../key/platform.keystore')
22+
storePassword 'android'
23+
}
24+
debug {
25+
keyAlias 'androiddebugkey'
26+
keyPassword 'android'
27+
storeFile file('../key/platform.keystore')
28+
storePassword 'android'
29+
}
30+
}
31+
32+
}
33+
34+
buildTypes {
35+
release {
36+
minifyEnabled false
37+
signingConfig signingConfigs.release
38+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
39+
}
40+
41+
debug{
42+
minifyEnabled false
43+
signingConfig signingConfigs.release
44+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
45+
}
46+
}
47+
48+
49+
}
50+
51+
dependencies {
52+
implementation fileTree(dir: 'libs', include: ['*.jar'])
53+
54+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
55+
testImplementation 'junit:junit:4.12'
56+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
57+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
58+
}

testmemorylink/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.testmemorylink;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.example.testmemorylink", appContext.getPackageName());
25+
}
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.testmemorylink"
4+
android:sharedUserId="android.uid.system">
5+
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme">
13+
<activity android:name=".MainActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
<activity android:name=".SecondActivity"></activity>
21+
</application>
22+
23+
</manifest>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example.testmemorylink;
2+
3+
import android.content.Context;
4+
5+
public class CommonUtils {
6+
private static CommonUtils instance;
7+
private Context context;
8+
9+
private CommonUtils(Context context) {
10+
this.context = context;
11+
}
12+
13+
public static CommonUtils getInstance(Context context) {
14+
if (instance == null) {
15+
instance = new CommonUtils(context);
16+
}
17+
return instance;
18+
}
19+
20+
}

0 commit comments

Comments
 (0)