• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.net.test.util;
6 
7 import org.chromium.base.ThreadUtils;
8 
9 import java.util.concurrent.FutureTask;
10 
11 /**
12  * A utility class useful for testing NetworkChangeNotifier.
13  */
14 public class NetworkChangeNotifierTestUtil {
15     /**
16      * Flushes UI thread task queue.
17      */
flushUiThreadTaskQueue()18     public static void flushUiThreadTaskQueue() throws Exception {
19         FutureTask<Void> task = new FutureTask<Void>(new Runnable() {
20             @Override
21             public void run() {}
22         }, null);
23         ThreadUtils.postOnUiThread(task);
24         task.get();
25     }
26 }
27