Commit b0e05326 authored by Karolina Soltys's avatar Karolina Soltys Committed by Commit Bot

[scheduler] Fixing bug in NativePostTaskTest.

Bug: 938316
Change-Id: I442d2adcf949227f91a1111921d609d908670953
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1503736
Commit-Queue: Karolina Soltys <ksolt@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarAlex Clarke <alexclarke@chromium.org>
Auto-Submit: Karolina Soltys <ksolt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638116}
parent 642f2e63
......@@ -61,14 +61,11 @@ public class NativePostTaskTest {
}
}
});
synchronized (lock) {
try {
while (!taskExecuted.get()) {
lock.wait();
}
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
......@@ -88,7 +85,6 @@ public class NativePostTaskTest {
Assert.assertFalse(taskExecuted.get());
startNativeScheduler();
try {
// The task should now be scheduled at some point after the delay, so the test shouldn't
// time out.
synchronized (lock) {
......@@ -96,9 +92,6 @@ public class NativePostTaskTest {
lock.wait();
}
}
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
@Test
......@@ -169,9 +162,9 @@ public class NativePostTaskTest {
public void testCreateTaskRunnerMigrationToNative() throws Exception {
final Object lock = new Object();
final AtomicBoolean taskExecuted = new AtomicBoolean();
TaskRunner taskQueue = PostTask.createSequencedTaskRunner(new TaskTraits());
TaskRunner taskQueue = PostTask.createTaskRunner(new TaskTraits());
taskQueue.postDelayedTask(new Runnable() {
postRepeatingTaskAndStartNativeSchedulerThenWaitForTaskToRun(taskQueue, new Runnable() {
@Override
public void run() {
synchronized (lock) {
......@@ -179,23 +172,18 @@ public class NativePostTaskTest {
lock.notify();
}
}
}, 1);
taskQueue.destroy();
// We verify that the task didn't get scheduled before the native scheduler is initialised
Assert.assertFalse(taskExecuted.get());
startNativeScheduler();
});
try {
// The task should now be scheduled at some point after the delay, so the test shouldn't
// The task should run at some point after the migration, so the test shouldn't
// time out.
synchronized (lock) {
while (!taskExecuted.get()) {
lock.wait();
}
}
} catch (InterruptedException ie) {
ie.printStackTrace();
} finally {
taskQueue.destroy();
}
}
......@@ -258,13 +246,9 @@ public class NativePostTaskTest {
nativeSchedulerStarted.set(true);
synchronized (lock) {
try {
while (!taskRun.get()) {
lock.wait();
}
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment