public TestFeatureRegistry build(String useFeature) throws GadgetException { return new TestFeatureRegistry( new TestFeatureResourceLoader(resourceMock), new TestCacheProvider(), useFeature); }
public String getDebugContent() { if (browserMatches()) { return delegate.getDebugContent(); } return ""; }
public String getContent() { if (browserMatches()) { return delegate.getContent(); } return ""; }
private void checkRegisterFromFileFeatureXml(boolean withScheme) throws Exception { TestFeatureRegistry.Builder builder = TestFeatureRegistry.newBuilder(); String content = "content-" + (withScheme ? "withScheme" : "noScheme"); Uri resUri = makeFile(content); Uri featureFile = makeFile(xml(NODEP_TPL, "gadget", withScheme ? resUri.toString() : resUri.getPath(), null)); registry = builder.build(withScheme ? featureFile.toString() : featureFile.getPath()); // Verify single resource works all the way through. List<FeatureResource> resources = registry.getAllFeatures().getResources(); assertEquals(1, resources.size()); assertEquals(content, resources.get(0).getContent()); }
protected FeatureResource loadResource( String path, Map<String, String> attribs) throws IOException { return new DualModeStaticResource(path, getResourceContent(getOptPath(path)), getResourceContent(path)); }
@Override public FeatureResource load(Uri uri, Map<String, String> attribs) throws GadgetException { return new BrowserSpecificFeatureResource( uaProvider, super.load(uri, attribs), attribs.get("browser")); } }
@SuppressWarnings("unused") protected FeatureResource loadFile(String path, Map<String, String> attribs) throws IOException { return new DualModeFileResource(getOptPath(path), path, attribs); }
/** * Helper method retrieving feature resources, including transitive dependencies. * @param ctx Context for the request. * @param needed List of all needed features. * @param unsupported If non-null, a List populated with unknown features from the needed list. * @return List of FeatureResources that may be used to render the needed features. */ public LookupResult getFeatureResources(GadgetContext ctx, Collection<String> needed, List<String> unsupported) { return getFeatureResources(ctx, needed, unsupported, true); }
@Override public boolean match(String in, String key) { return num(in).lt(num(key)); } },
public BrowserSpecificFeatureResource( Provider<UserAgent> uaProvider, FeatureResource delegate, String browserKey) { this.uaProvider = uaProvider; this.delegate = delegate; this.browserMatch = populateBrowserMatchers(browserKey); }
private UriResource(HttpFetcher fetcher, Uri uri, boolean isInline) { this.fetcher = fetcher; this.uri = uri; this.isInline = isInline; this.lastLoadTryMs = 0; this.content = getContent(); }
private FeatureResource extern(String content, String debugContent) { return new FeatureResource.Simple(content, debugContent, "js") { @Override public boolean isExternal() { return true; } }; }
private void checkRegisterFromFileFeatureXml(boolean withScheme) throws Exception { TestFeatureRegistry.Builder builder = TestFeatureRegistry.newBuilder(); String content = "content-" + (withScheme ? "withScheme" : "noScheme"); Uri resUri = makeFile(content); Uri featureFile = makeFile(xml(NODEP_TPL, "gadget", withScheme ? resUri.toString() : resUri.getPath(), null)); registry = builder.build(withScheme ? featureFile.toString() : featureFile.getPath()); // Verify single resource works all the way through. List<FeatureResource> resources = registry.getAllFeatures().getResources(); assertEquals(1, resources.size()); assertEquals(content, resources.get(0).getContent()); }
public String getDebugContent() { if (browserMatches()) { return delegate.getDebugContent(); } return ""; }
public String getContent() { if (browserMatches()) { return delegate.getContent(); } return ""; }
protected FeatureResource loadResource( String path, Map<String, String> attribs) throws IOException { return new DualModeStaticResource(path, getResourceContent(getOptPath(path)), getResourceContent(path)); }
protected FeatureResource loadFile(String path, Map<String, String> attribs) throws IOException { return new DualModeFileResource(getOptPath(path), path); }
public String getDebugContent() { if (browserMatches()) { return delegate.getDebugContent(); } return ""; }
public String getContent() { if (browserMatches()) { return delegate.getContent(); } return ""; }
protected FeatureResource loadFile(String path, Map<String, String> attribs) throws IOException { return new DualModeFileResource(getOptPath(path), path); }