1 /* 2 * Copyright (C) 2010 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 17 package com.android.mms.util; 18 19 import java.util.Locale; 20 21 import android.test.AndroidTestCase; 22 import android.test.suitebuilder.annotation.SmallTest; 23 24 import com.android.mms.transaction.HttpUtils; 25 26 /** 27 * Unit tests for HttpUtils. 28 * 29 * To run the test: 30 * runtest --test-class=com.android.mms.util.HttpUtilsTests mms 31 */ 32 @SmallTest 33 public class HttpUtilsTests extends AndroidTestCase { 34 35 /** 36 * This tests the standard behavior of HttpUtils.getCurrentAcceptLanguage with the 37 * default locale. 38 */ testDefaultAcceptLanguage()39 public void testDefaultAcceptLanguage() { 40 Locale defaultLocale = Locale.getDefault(); 41 String curAcceptLang = HttpUtils.getCurrentAcceptLanguage(defaultLocale); 42 43 assertTrue("Accept language code doesn't match language", 44 curAcceptLang.startsWith(defaultLocale.getLanguage())); 45 } 46 47 /** 48 * This tests the behavior of HttpUtils.getCurrentAcceptLanguage with a 49 * deprecated language code. Check to make sure we're getting back the new language code. 50 */ testDeprecatedLanguage()51 public void testDeprecatedLanguage() { 52 Locale hebrewLocale = new Locale("iw", "IW"); 53 String curAcceptLang = HttpUtils.getCurrentAcceptLanguage(hebrewLocale); 54 55 assertTrue("Hewbrew language code wasn't converted to 'he'", 56 curAcceptLang.startsWith("he")); 57 } 58 59 } 60