diff options
author | scheib <scheib@chromium.org> | 2015-06-30 15:26:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-30 22:27:37 +0000 |
commit | 545d7fd0b4de41af907c1ad01f72b492f01f9d3c (patch) | |
tree | e1987c48ae5f716297d071920c4f37a848e465de /device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java | |
parent | b24a7e02ef7d7e1551cd1cadb96a50bdfa3fe283 (diff) | |
download | chromium_src-545d7fd0b4de41af907c1ad01f72b492f01f9d3c.zip chromium_src-545d7fd0b4de41af907c1ad01f72b492f01f9d3c.tar.gz chromium_src-545d7fd0b4de41af907c1ad01f72b492f01f9d3c.tar.bz2 |
bluetooth: android: Refactor tests, wrappers, and fakes.
Refactoring to simplify follow up patch
"Initial Low Energy Discovery Sessions"
https://codereview.chromium.org/1150833002
Android wrapper and fake classes are refactored to be inner classes
because many more wrapper and fake classes are being implemented.
Testing code is refactored to be run in cross platform files
(e.g. bluetooth_adapter_unittest.cc), with a test fixture
BluetoothTest that is be subclassed to enable tests
on multiple platforms.
Tests implemented for Android will be done in this new style,
encapsulating Android specific details so that the tests may
be used on other platforms as well. E.g. the anticipated
Mac OSX support can us these tests instead of creating additional
platform specific tests. The larger test suites of ChromeOS
may some day be refactored to this style as well, adding coverage
for all platforms.
BUG=488575
Review URL: https://codereview.chromium.org/1216473005
Cr-Commit-Position: refs/heads/master@{#336894}
Diffstat (limited to 'device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java')
-rw-r--r-- | device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java b/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java new file mode 100644 index 0000000..c5adcf7 --- /dev/null +++ b/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java @@ -0,0 +1,61 @@ +// 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.device.bluetooth; + +import org.chromium.base.CalledByNative; +import org.chromium.base.Log; + +/** + * Fake implementations of android.bluetooth.* classes for testing. + */ +class Fakes { + private static final String TAG = "cr.Bluetooth"; + + /** + * Fakes android.bluetooth.BluetoothAdapter. + */ + static class FakeBluetoothAdapter extends Wrappers.BluetoothAdapterWrapper { + /** + * Creates a FakeBluetoothAdapter. + */ + @CalledByNative("FakeBluetoothAdapter") + public static FakeBluetoothAdapter create() { + Log.v(TAG, "FakeBluetoothAdapter created."); + return new FakeBluetoothAdapter(); + } + + private FakeBluetoothAdapter() { + super(null); + } + + // ----------------------------------------------------------------------------------------- + // BluetoothAdapterWrapper overrides: + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getAddress() { + return "A1:B2:C3:D4:E5:F6"; + } + + @Override + public String getName() { + return "FakeBluetoothAdapter"; + } + + @Override + public int getScanMode() { + return android.bluetooth.BluetoothAdapter.SCAN_MODE_NONE; + } + + @Override + public boolean isDiscovering() { + return false; + } + } +} |