Codota Logo
ShadowCanvas.getDescription
Code IndexAdd Codota to your IDE (free)

How to use
getDescription
method
in
org.robolectric.shadows.ShadowCanvas

Best Java code snippets using org.robolectric.shadows.ShadowCanvas.getDescription (Showing top 20 results out of 315)

  • Common ways to obtain ShadowCanvas
private void myMethod () {
ShadowCanvas s =
  • Codota IconObject instance;(ShadowCanvas) Shadow.extract(instance)
  • Smart code suggestions by Codota
}
origin: robolectric/robolectric

private void separateLines() {
 if (getDescription().length() != 0) {
  appendDescription("\n");
 }
}
origin: robolectric/robolectric

/**
 * Returns a textual representation of the appearance of the object.
 *
 * @param view the view to visualize
 * @return Textual representation of the appearance of the object.
 */
public static String visualize(View view) {
 Canvas canvas = new Canvas();
 view.draw(canvas);
 ShadowCanvas shadowCanvas = Shadow.extract(canvas);
 return shadowCanvas.getDescription();
}
origin: robolectric/robolectric

/**
 * Returns a textual representation of the appearance of the object.
 *
 * @param canvas the canvas to visualize
 * @return The textual representation of the appearance of the object.
 */
public static String visualize(Canvas canvas) {
 ShadowCanvas shadowCanvas = Shadow.extract(canvas);
 return shadowCanvas.getDescription();
}
origin: facebook/litho

/**
 * Tries to extract the description of a drawn drawable from a canvas
 */
static String getDrawnDrawableDescription(final Drawable drawable) {
 final Canvas canvas = new Canvas();
 drawable.draw(canvas);
 final ShadowCanvas shadowCanvas = Shadows.shadowOf(canvas);
 return shadowCanvas.getDescription();
}
origin: facebook/litho

/**
 * Tries to extract the description of a drawn view from a canvas
 *
 * Since Robolectric can screw up {@link View#draw}, this uses reflection to call
 * {@link View#onDraw} and give you a canvas that has all the information drawn into it.
 * This is useful for asserting some view draws something specific to a canvas.
 *
 * @param view the view to draw
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private static String getDrawnViewDescription(View view) {
 final Canvas canvas = new Canvas();
 view.draw(canvas);
 final ShadowCanvas shadowCanvas = Shadows.shadowOf(canvas);
 if (!shadowCanvas.getDescription().isEmpty()) {
  return shadowCanvas.getDescription();
 }
 try {
  final Method onDraw = view.getClass().getMethod("onDraw", Canvas.class);
  onDraw.setAccessible(true);
  onDraw.invoke(view, canvas);
  final ShadowCanvas shadowCanvas2 = Shadows.shadowOf(canvas);
  return shadowCanvas2.getDescription();
 } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
  throw new RuntimeException(e);
 }
}
origin: robolectric/robolectric

@Test
public void shouldDescribeBitmapDrawing_withDestinationRectF() throws Exception {
 Canvas canvas = new Canvas(targetBitmap);
 canvas.drawBitmap(imageBitmap, new Rect(1,2,3,4), new RectF(5.0f,6.0f,7.5f,8.5f), new Paint());
 assertEquals("Bitmap for file:/an/image.jpg at (5.0,6.0) with height=2.5 and width=2.5 taken from Rect(1, 2 - 3, 4)", shadowOf(canvas).getDescription());
}
origin: robolectric/robolectric

@Test
public void shouldDescribeBitmapDrawing_withDestinationRect() throws Exception {
 Canvas canvas = new Canvas(targetBitmap);
 canvas.drawBitmap(imageBitmap, new Rect(1,2,3,4), new Rect(5,6,7,8), new Paint());
 assertEquals("Bitmap for file:/an/image.jpg at (5,6) with height=2 and width=2 taken from Rect(1, 2 - 3, 4)", shadowOf(canvas).getDescription());
}
origin: robolectric/robolectric

@Test
public void drawColor_shouldReturnDescription() throws Exception {
 Canvas canvas = new Canvas(targetBitmap);
 canvas.drawColor(Color.WHITE);
 canvas.drawColor(Color.GREEN);
 canvas.drawColor(Color.TRANSPARENT);
 assertEquals("draw color -1draw color -16711936draw color 0",
   shadowOf(canvas).getDescription());
}
origin: robolectric/robolectric

@Test
public void shouldDescribeBitmapDrawing_WithMatrix() throws Exception {
 Canvas canvas = new Canvas(targetBitmap);
 canvas.drawBitmap(imageBitmap, new Matrix(), new Paint());
 canvas.drawBitmap(imageBitmap, new Matrix(), new Paint());
 assertEquals("Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]\n" +
   "Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]", shadowOf(canvas).getDescription());
 assertEquals("Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]\n" +
   "Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]", shadowOf(targetBitmap).getDescription());
}
origin: robolectric/robolectric

@Test
public void draw_shouldCopyDescriptionToCanvas() throws Exception {
 BitmapDrawable drawable = (BitmapDrawable) resources.getDrawable(R.drawable.an_image);
 Canvas canvas = new Canvas();
 drawable.draw(canvas);
 assertThat(shadowOf(canvas).getDescription()).isEqualTo("Bitmap for resource:org.robolectric:drawable/an_image");
}
origin: robolectric/robolectric

@Test
public void resetCanvasHistory_shouldClearTheHistoryAndDescription() throws Exception {
 Canvas canvas = new Canvas();
 canvas.drawPath(new Path(), new Paint());
 canvas.drawText("hi", 1, 2, new Paint());
 ShadowCanvas shadow = shadowOf(canvas);
 shadow.resetCanvasHistory();
 assertThat(shadow.getPathPaintHistoryCount()).isEqualTo(0);
 assertThat(shadow.getTextHistoryCount()).isEqualTo(0);
 assertEquals("", shadow.getDescription());
}
origin: robolectric/robolectric

@Test
public void shouldDescribeBitmapDrawing() throws Exception {
 Canvas canvas = new Canvas(targetBitmap);
 canvas.drawBitmap(imageBitmap, 1, 2, new Paint());
 canvas.drawBitmap(imageBitmap, 100, 200, new Paint());
 assertEquals("Bitmap for file:/an/image.jpg at (1,2)\n" +
   "Bitmap for file:/an/image.jpg at (100,200)", shadowOf(canvas).getDescription());
 assertEquals("Bitmap for file:/an/image.jpg at (1,2)\n" +
   "Bitmap for file:/an/image.jpg at (100,200)", shadowOf(targetBitmap).getDescription());
}
origin: robolectric/robolectric

@Test
public void drawPath_shouldAppendDescriptionToBitmap() throws Exception {
 Canvas canvas = new Canvas(targetBitmap);
 Path path1 = new Path();
 path1.lineTo(10, 10);
 path1.moveTo(20, 15);
 Path path2 = new Path();
 path2.moveTo(100, 100);
 path2.lineTo(150, 140);
 Paint paint = new Paint();
 canvas.drawPath(path1, paint);
 canvas.drawPath(path2, paint);
 assertEquals("Path " + shadowOf(path1).getPoints().toString() + "\n"
   + "Path " + shadowOf(path2).getPoints().toString(), shadowOf(canvas).getDescription());
 assertEquals("Path " + shadowOf(path1).getPoints().toString() + "\n"
   + "Path " + shadowOf(path2).getPoints().toString(), shadowOf(targetBitmap).getDescription());
}
origin: robolectric/robolectric

@Test
public void withColorFilterSet_draw_shouldCopyDescriptionToCanvas() throws Exception {
 BitmapDrawable drawable = (BitmapDrawable) resources.getDrawable(R.drawable.an_image);
 drawable.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix()));
 Canvas canvas = new Canvas();
 drawable.draw(canvas);
 assertThat(shadowOf(canvas).getDescription()).isEqualTo("Bitmap for resource:org.robolectric:drawable/an_image with ColorMatrixColorFilter<1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0>");
}
origin: org.robolectric/framework

/**
 * Returns a textual representation of the appearance of the object.
 *
 * @param canvas the canvas to visualize
 * @return The textual representation of the appearance of the object.
 */
public static String visualize(Canvas canvas) {
 return shadowOf(canvas).getDescription();
}
origin: org.robolectric/shadows-core

private void separateLines() {
 if (getDescription().length() != 0) {
  appendDescription("\n");
 }
}
origin: org.robolectric/shadows-core

/**
 * Returns a textual representation of the appearance of the object.
 *
 * @param canvas the canvas to visualize
 * @return The textual representation of the appearance of the object.
 */
public static String visualize(Canvas canvas) {
 return shadowOf(canvas).getDescription();
}
origin: org.robolectric/shadows-core-v23

/**
 * Returns a textual representation of the appearance of the object.
 *
 * @param view the view to visualize
 * @return Textual representation of the appearance of the object.
 */
public static String visualize(View view) {
 Canvas canvas = new Canvas();
 view.draw(canvas);
 return shadowOf(canvas).getDescription();
}
origin: org.robolectric/shadows-core-v23

/**
 * Returns a textual representation of the appearance of the object.
 *
 * @param canvas the canvas to visualize
 * @return The textual representation of the appearance of the object.
 */
public static String visualize(Canvas canvas) {
 return shadowOf(canvas).getDescription();
}
origin: org.robolectric/shadows-framework

/**
 * Returns a textual representation of the appearance of the object.
 *
 * @param canvas the canvas to visualize
 * @return The textual representation of the appearance of the object.
 */
public static String visualize(Canvas canvas) {
 ShadowCanvas shadowCanvas = Shadow.extract(canvas);
 return shadowCanvas.getDescription();
}
org.robolectric.shadowsShadowCanvasgetDescription

Popular methods of ShadowCanvas

  • getPathPaintHistoryCount
  • appendDescription
  • describeBitmap
  • separateLines
  • formatColorMatric
  • getArcPaintHistoryCount
  • getDrawnArc
  • getDrawnCircle
  • getDrawnLine
  • getDrawnOval
  • getDrawnPath
  • getDrawnPathPaint
  • getDrawnPath,
  • getDrawnPathPaint,
  • getDrawnRect,
  • getDrawnTextEvent,
  • getLinePaintHistoryCount,
  • getOvalPaintHistoryCount,
  • getRectPaintHistoryCount,
  • getTextHistoryCount,
  • resetCanvasHistory

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • runOnUiThread (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • PrintWriter (java.io)
    Prints formatted representations of objects to a text-output stream. This class implements all of th
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Reference (javax.naming)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now