1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.bluetooth.le; 18 19import android.test.suitebuilder.annotation.SmallTest; 20 21import junit.framework.TestCase; 22 23/** 24 * Test for Bluetooth LE {@link ScanSettings}. 25 */ 26public class ScanSettingsTest extends TestCase { 27 28 @SmallTest 29 public void testCallbackType() { 30 ScanSettings.Builder builder = new ScanSettings.Builder(); 31 builder.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES); 32 builder.setCallbackType(ScanSettings.CALLBACK_TYPE_FIRST_MATCH); 33 builder.setCallbackType(ScanSettings.CALLBACK_TYPE_MATCH_LOST); 34 builder.setCallbackType( 35 ScanSettings.CALLBACK_TYPE_FIRST_MATCH | ScanSettings.CALLBACK_TYPE_MATCH_LOST); 36 try { 37 builder.setCallbackType( 38 ScanSettings.CALLBACK_TYPE_ALL_MATCHES | ScanSettings.CALLBACK_TYPE_MATCH_LOST); 39 fail("should have thrown IllegalArgumentException!"); 40 } catch (IllegalArgumentException e) { 41 // nothing to do 42 } 43 44 try { 45 builder.setCallbackType( 46 ScanSettings.CALLBACK_TYPE_ALL_MATCHES | 47 ScanSettings.CALLBACK_TYPE_FIRST_MATCH); 48 fail("should have thrown IllegalArgumentException!"); 49 } catch (IllegalArgumentException e) { 50 // nothing to do 51 } 52 53 try { 54 builder.setCallbackType( 55 ScanSettings.CALLBACK_TYPE_ALL_MATCHES | 56 ScanSettings.CALLBACK_TYPE_FIRST_MATCH | 57 ScanSettings.CALLBACK_TYPE_MATCH_LOST); 58 fail("should have thrown IllegalArgumentException!"); 59 } catch (IllegalArgumentException e) { 60 // nothing to do 61 } 62 63 } 64} 65