Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1695)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/VibrationManagerImplTest.java

Issue 2774783003: [DeviceService] Add service tests for VibrationManager. (Closed)
Patch Set: Address comments from blundell@ Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/android/BUILD.gn ('k') | device/vibration/android/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/VibrationManagerImplTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/VibrationManagerImplTest.java b/content/public/android/javatests/src/org/chromium/content/browser/VibrationManagerImplTest.java
deleted file mode 100644
index 7db250abf155aeb9169add200893a8071f212675..0000000000000000000000000000000000000000
--- a/content/public/android/javatests/src/org/chromium/content/browser/VibrationManagerImplTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.content.browser;
-
-import android.os.Vibrator;
-import android.support.test.filters.MediumTest;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.chromium.base.test.BaseJUnit4ClassRunner;
-import org.chromium.base.test.util.DisabledTest;
-import org.chromium.base.test.util.Feature;
-import org.chromium.base.test.util.UrlUtils;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
-import org.chromium.content_shell_apk.ContentShellActivityTestRule;
-import org.chromium.device.vibration.VibrationManagerImpl;
-
-/**
- * Tests java implementation of VibrationManager mojo service on android.
- */
-@RunWith(BaseJUnit4ClassRunner.class)
-public class VibrationManagerImplTest {
- @Rule
- public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule();
-
- private static final String URL_VIBRATOR_VIBRATE = UrlUtils.encodeHtmlDataUri("<html><body>"
- + " <script type=\"text/javascript\">"
- + " navigator.vibrate(3000);"
- + " </script>"
- + "</body></html>");
- private static final String URL_VIBRATOR_CANCEL = UrlUtils.encodeHtmlDataUri("<html><body>"
- + " <script type=\"text/javascript\">"
- + " navigator.vibrate(10000);"
- + " navigator.vibrate(0);"
- + " </script>"
- + "</body></html>");
-
- private FakeAndroidVibratorWrapper mFakeWrapper;
-
- // Override AndroidVibratorWrapper API to record the calling.
- private static class FakeAndroidVibratorWrapper
- extends VibrationManagerImpl.AndroidVibratorWrapper {
- // Record the parameters of vibrate() and cancel().
- public long mMilliSeconds;
- public boolean mCancelled;
-
- protected FakeAndroidVibratorWrapper() {
- super();
- mMilliSeconds = -1;
- mCancelled = false;
- }
-
- @Override
- public void vibrate(Vibrator vibrator, long milliseconds) {
- mMilliSeconds = milliseconds;
- }
-
- @Override
- public void cancel(Vibrator vibrator) {
- mCancelled = true;
- }
- }
-
- @Before
- public void setUp() throws Exception {
- mActivityTestRule.launchContentShellWithUrl("about:blank");
- mActivityTestRule.waitForActiveShellToBeDoneLoading();
-
- mFakeWrapper = new FakeAndroidVibratorWrapper();
- VibrationManagerImpl.setVibratorWrapperForTesting(mFakeWrapper);
- Assert.assertEquals(-1, mFakeWrapper.mMilliSeconds);
- Assert.assertFalse(mFakeWrapper.mCancelled);
- }
-
- /**
- * Inject our fake wrapper into VibrationManagerImpl,
- * load the webpage which will request vibrate for 3000 milliseconds,
- * the fake wrapper vibrate() should be called and 3000 milliseconds should be recorded
- * correctly.
- */
- // @MediumTest
- // @Feature({"Vibration"})
- @Test
- @DisabledTest
- public void testVibrate() throws Throwable {
- mActivityTestRule.loadNewShell(URL_VIBRATOR_VIBRATE);
-
- // Waits until VibrationManagerImpl.Vibrate() got called.
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mFakeWrapper.mMilliSeconds != -1;
- }
- });
-
- Assert.assertEquals(
- "Did not get vibrate mMilliSeconds correctly", 3000, mFakeWrapper.mMilliSeconds);
- }
-
- /**
- * Inject our fake wrapper into VibrationManagerImpl,
- * load the webpage which will request vibrate and then request cancel,
- * the fake wrapper cancel() should be called.
- */
- @Test
- @MediumTest
- @Feature({"Vibration"})
- public void testCancel() throws Throwable {
- mActivityTestRule.loadNewShell(URL_VIBRATOR_CANCEL);
-
- // Waits until VibrationManagerImpl.Cancel() got called.
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mFakeWrapper.mCancelled;
- }
- });
-
- Assert.assertTrue("Did not get cancelled", mFakeWrapper.mCancelled);
- }
-}
« no previous file with comments | « content/public/android/BUILD.gn ('k') | device/vibration/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698