Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Tor Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
Android Libs
Tor Android
Commits
09de98dd
Commit
09de98dd
authored
3 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Wait for service to stop at the end of each test.
parent
977d79a9
Branches
Branches containing commit
No related tags found
1 merge request
!2
update upstream
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tor-android-binary/src/androidTest/java/org/torproject/jni/TorServiceTest.java
+8
-0
8 additions, 0 deletions
...c/androidTest/java/org/torproject/jni/TorServiceTest.java
with
8 additions
and
0 deletions
tor-android-binary/src/androidTest/java/org/torproject/jni/TorServiceTest.java
+
8
−
0
View file @
09de98dd
...
...
@@ -174,6 +174,7 @@ public class TorServiceTest {
FileUtils
.
write
(
torrc
,
dnsPort
+
" "
+
testValue
+
"\n"
);
final
CountDownLatch
startedLatch
=
new
CountDownLatch
(
1
);
final
CountDownLatch
stoppedLatch
=
new
CountDownLatch
(
1
);
BroadcastReceiver
receiver
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
...
...
@@ -185,6 +186,8 @@ public class TorServiceTest {
Log
.
i
(
TAG
,
"receiver.onReceive: "
+
status
+
" "
+
intent
);
if
(
TorService
.
STATUS_ON
.
equals
(
status
))
{
startedLatch
.
countDown
();
}
else
if
(
TorService
.
STATUS_OFF
.
equals
(
status
))
{
stoppedLatch
.
countDown
();
}
}
};
...
...
@@ -203,12 +206,14 @@ public class TorServiceTest {
assertEquals
(
testValue
,
getConf
(
torService
.
getTorControlConnection
(),
dnsPort
));
serviceRule
.
unbindService
();
stoppedLatch
.
await
();
}
@Test
public
void
testDownloadingLargeFile
()
throws
TimeoutException
,
InterruptedException
,
IOException
{
Assume
.
assumeTrue
(
"Only works on Android 7.1.2 or higher"
,
Build
.
VERSION
.
SDK_INT
>=
24
);
final
CountDownLatch
startedLatch
=
new
CountDownLatch
(
1
);
final
CountDownLatch
stoppedLatch
=
new
CountDownLatch
(
1
);
BroadcastReceiver
receiver
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
...
...
@@ -220,6 +225,8 @@ public class TorServiceTest {
Log
.
i
(
TAG
,
"receiver.onReceive: "
+
status
+
" "
+
intent
);
if
(
TorService
.
STATUS_ON
.
equals
(
status
))
{
startedLatch
.
countDown
();
}
else
if
(
TorService
.
STATUS_OFF
.
equals
(
status
))
{
stoppedLatch
.
countDown
();
}
}
};
...
...
@@ -252,6 +259,7 @@ public class TorServiceTest {
IOUtils
.
copy
(
connection
.
getInputStream
(),
new
FileWriter
(
new
File
(
"/dev/null"
)));
serviceRule
.
unbindService
();
stoppedLatch
.
await
();
}
private
static
boolean
canConnectToSocket
(
String
host
,
int
port
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment