| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.accounts; |
| 18 |
|
| 19 |
import static junit.framework.Assert.fail; |
| 20 |
|
| 21 |
import android.Manifest; |
| 22 |
import android.content.Context; |
| 23 |
import android.content.pm.PackageManager; |
| 24 |
import android.perftests.utils.BenchmarkState; |
| 25 |
import android.perftests.utils.PerfStatusReporter; |
| 26 |
|
| 27 |
import androidx.test.InstrumentationRegistry; |
| 28 |
import androidx.test.filters.LargeTest; |
| 29 |
import androidx.test.runner.AndroidJUnit4; |
| 30 |
|
| 31 |
import org.junit.Rule; |
| 32 |
import org.junit.Test; |
| 33 |
import org.junit.runner.RunWith; |
| 34 |
|
| 35 |
@RunWith(AndroidJUnit4.class) |
| 36 |
@LargeTest |
| 37 |
public class AccountManagerPerfTest { |
| 38 |
|
| 39 |
@Rule |
| 40 |
public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); |
| 41 |
|
| 42 |
@Test |
| 43 |
public void testGetAccounts() { |
| 44 |
BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); |
| 45 |
final Context context = InstrumentationRegistry.getTargetContext(); |
| 46 |
if (context.checkSelfPermission(Manifest.permission.GET_ACCOUNTS) |
| 47 |
!= PackageManager.PERMISSION_GRANTED) { |
| 48 |
fail("Missing required GET_ACCOUNTS permission"); |
| 49 |
} |
| 50 |
AccountManager accountManager = AccountManager.get(context); |
| 51 |
while (state.keepRunning()) { |
| 52 |
accountManager.getAccounts(); |
| 53 |
} |
| 54 |
} |
| 55 |
} |