我试图在我的UIAutomator测试中使用Firebase上的测试实验室中的ScreenShotter功能。
然而,不仅仅需要一个上下文,它需要一个Activity,而我无法在UIAutomator测试中获得或没有。
我搞砸了这只适用于Espresso吗?
答案 0 :(得分:0)
如果需要,您可以使用 function hourString(hour) {
if (hour === 0) {
return "12:00 am";
}
if (hour < 12) {
return hour + ":00 am";
}
if (hour === 12) {
return "12:00 pm";
}
return (hour - 12) + ":00 pm";
}
var ordersPackChart;
function packResult(historydate, result) {
result = JSON.parse(result);
var data = [];
for (var hour = 6; hour < 24; hour++) {
var numberPack = 0;
for (var i = 0; i < result.Result.length; i++) {
if (result.Result[i].PACK_HOUR == hour) {
numberPack = result.Result[i].NUM_ORDER_PACK;
break;
}
}
data.push({ y: hourString(hour), a: numberPack });
}
if (ordersPackChart != null) {
ordersPackChart.setData(data);
} else {
ordersPackChart =
Morris.Bar({
element: 'morris-bar-chart',
data: data,
xkey: 'y',
ykeys: ['a'],
ymax: 1000,
labels: ['Pack per hour'],
hideHover: true,
resize: true,
barColors: ['#ed5565'],
parseTime: false
});
}
}
$(document).ready(function () {
$("#fromdate").datepicker({
autoclose: true
}).change(dateChanged);
});
var currentDay;
function dateChanged(ev) {
$(this).datepicker('hide');
var day = $('#fromdate').val();
if (day == currentDay)
return;
currentDay = day;
$.ajax({
type: "GET",
url: '@Url.Action("GetQueryResult")',
context: document.body,
data: {
querySetName: 'dashboard-packorder-statistics',
queryName: 'OrderPack',
historydate: day
},
success: function (result) {
packResult(day, result);
},
error: function (xhr) {
var message = "ErrorStatus: " + xhr.status + " ReadyState: " + xhr.readyState;
}
});
}
并使用Espresso和UiAutomator。
ActivityInstrumentationTestCase2