This source file includes following definitions.
- getImageSourceNoAdvance
- getPageTemplateSource
- getPageSource
- getPageUrl
package org.chromium.android_webview.test.util;
import org.chromium.net.test.util.TestWebServer;
public class ImagePageGenerator {
public static final String IMAGE_LOADED_STRING = "1";
public static final String IMAGE_NOT_LOADED_STRING = "0";
private static final String[] COLORS = {
"AAAAIAAc3j0Ss", "AQABIAEayS9b0", "AgACIAIQ8BmAc", "AwADIAMW5wvJE",
"BAAEIAQZNWRTI", "BQAFIAUfInYaQ", "BgAGIAYVG0DB4", "BwAHIAcTDFKIg",
"CAAIIAgXCI+Rk", "CQAJIAkRH53Y8", "CgAKIAobJqsDU", "CwALIAsdMblKM",
"DAAMIAwS49bQA", "DQANIA0U9MSZY", "DgAOIA4ezfJCw", "DwAPIA8Y2uALo",
"D+AQAA/9vaUwc", "D/AQEBANNhzkw"
};
private static final String IMAGE_PREFIX = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA" +
"6fptVAAAAAXNSR0IArs4c6QAAAA1JREFUCB0BAgD9/w";
private static final String IMAGE_SUFFIX = "AAAAASUVORK5CYII=";
private int mIndex;
private final boolean mAdvance;
public ImagePageGenerator(int startIndex, boolean advance) {
mIndex = startIndex;
mAdvance = advance;
}
public String getImageSourceNoAdvance() {
return IMAGE_PREFIX + COLORS[mIndex] + IMAGE_SUFFIX;
}
public String getPageTemplateSource(String imageSrc) {
return CommonResources.getOnImageLoadedHtml(imageSrc);
}
public String getPageSource() {
String result =
getPageTemplateSource("data:image/png;base64," + getImageSourceNoAdvance());
if (mAdvance) mIndex += 2;
return result;
}
public String getPageUrl(TestWebServer webServer) {
final String imagePath = "/image_" + mIndex + ".png";
final String pagePath = "/html_image_" + mIndex + ".html";
webServer.setResponseBase64(imagePath, getImageSourceNoAdvance(),
CommonResources.getImagePngHeaders(false));
if (mAdvance) mIndex += 2;
return webServer.setResponse(pagePath, getPageTemplateSource(imagePath), null);
}
}