当前位置: 首页>>代码示例>>Java>>正文


Java MockResources类代码示例

本文整理汇总了Java中android.test.mock.MockResources的典型用法代码示例。如果您正苦于以下问题:Java MockResources类的具体用法?Java MockResources怎么用?Java MockResources使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MockResources类属于android.test.mock包,在下文中一共展示了MockResources类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResources

import android.test.mock.MockResources; //导入依赖的package包/类
@Override
public Resources getResources() {
    Resources res = new MockResources() {
        @Override
        // The actual selects singular vs plural as well and in the given language
        public String getQuantityString(int id, int quantity) {
            if (id == R.plurals.Nmins) {
                return quantity + " mins";
            }
            if (id == R.plurals.Nminutes) {
                return quantity + " minutes";
            }
            if (id == R.plurals.Nhours) {
                return quantity + " hours";
            }
            if (id == R.plurals.Ndays) {
                return quantity + " days";
            }
            return id + " " + quantity;
        }
    };
    return res;
}
 
开发者ID:x7hub,项目名称:Calendar_lunar,代码行数:24,代码来源:EditEventHelperTest.java

示例2: getTestCalc

import android.test.mock.MockResources; //导入依赖的package包/类
/**
 * Used to get a test calculator with a mocked resource file
 *
 * @return test calculator
 */
private Calculator getTestCalc() {
	//TODO make this into something cleaner--use Mockito to completely fake the resource
	MockResources mockResources = new MockResources() {
		@Override
		public String[] getStringArray(int id) {
			if (id == R.array.unit_type_array_combined){
				return new String[]{"key_currency|Currency|Currency", "key_temp|Temperature|Temp", "key_weight|Weight|Weight", "key_len|Length|Length", "key_area|Area|Area", "key_vol|Volume|Volume", "key_speed|Speed|Speed", "key_time|Time|Time", "key_fuel|FuelEconomy|FuelEco", "key_power|Power|Power", "key_energy|Energy|Energy", "key_force|Force|Force", "key_torque|Torque|Torque", "key_pressure|Pressure|Pressure", "key_digital|DigitalStorage|Digital"};
			}
			return null;
		}
	};
	return Calculator.getTestCalculator(mockResources);
}
 
开发者ID:EvanRespaut,项目名称:Equate,代码行数:19,代码来源:CalculatorJUnitTest.java

示例3: testGetStringResource

import android.test.mock.MockResources; //导入依赖的package包/类
public void testGetStringResource() {
	MockResources mockResources = new MyMockResources();

	String actual = mainActivity.getStringResource(mockResources);

	assertEquals("string", actual);
}
 
开发者ID:android10,项目名称:Inside_Android_Testing,代码行数:8,代码来源:MainActivityTest.java


注:本文中的android.test.mock.MockResources类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。