public void reset() { Config config = Config.get(); vibrateOn = config.getBoolean("key_vibrate"); duration = config.getInt("key_vibrate_duration"); if (vibrateOn && (vibrator == null)) { vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); } soundOn = config.getBoolean("key_sound"); volume = config.getFloat("key_sound_volume"); if (soundOn && (audioManager == null)) { audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); } isSpeakCommit = config.getBoolean("speak_commit"); isSpeakKey = config.getBoolean("speak_key"); if (mTTS == null && (isSpeakCommit || isSpeakKey)) { mTTS = new TextToSpeech( context, new TextToSpeech.OnInitListener() { public void onInit(int status) { // 初始化結果 } }); } }
@Test(expected = NumberFormatException.class) public void getFloatNFE() throws Exception { final Config config = new Config(); config.overrideConfig("asynchbase.float", "this can't be parsed to float"); config.getFloat("asynchbase.float"); }
@Test(expected = NullPointerException.class) public void getFloatDoesNotExist() throws Exception { final Config config = new Config(); config.getFloat("asynchbase.nosuchkey"); }
@Test(expected = NullPointerException.class) public void getFloatNull() throws Exception { final Config config = new Config(); config.overrideConfig("asynchbase.null", null); config.getFloat("asynchbase.null"); }
@Test public void getFloatNegative() throws Exception { final Config config = new Config(); config.overrideConfig("asynchbase.float", Float.toString(Float.MIN_VALUE)); assertEquals(Float.MIN_VALUE, config.getFloat("asynchbase.float"), 0.000001); }