Index: samplecode/SampleText.cpp |
diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp |
index 87ca91406b7060438cba25e85022f8f60f98ee6e..f5f8dbefa0b6ef7e35ab167ab3941a1bd4137313 100644 |
--- a/samplecode/SampleText.cpp |
+++ b/samplecode/SampleText.cpp |
@@ -27,6 +27,41 @@ |
#include "SkStream.h" |
#include "SkXMLParser.h" |
+static void test_breakText() { |
+ SkPaint paint; |
+ const char* text = "sdfkljAKLDFJKEWkldfjlk#$%&sdfs.dsj"; |
+ size_t length = strlen(text); |
+ SkScalar width = paint.measureText(text, length); |
+ |
+ SkScalar mm = 0; |
+ SkScalar nn = 0; |
+ for (SkScalar w = 0; w <= width; w += SK_Scalar1) { |
+ SkScalar m; |
+ size_t n = paint.breakText(text, length, w, &m); |
+ |
+ SkASSERT(n <= length); |
+ SkASSERT(m <= width); |
+ |
+ if (n == 0) { |
+ SkASSERT(m == 0); |
+ } else { |
+ // now assert that we're monotonic |
+ if (n == nn) { |
+ SkASSERT(m == mm); |
+ } else { |
+ SkASSERT(n > nn); |
+ SkASSERT(m > mm); |
+ } |
+ } |
+ nn = SkIntToScalar((unsigned int)n); |
+ mm = m; |
+ } |
+ |
+ SkDEBUGCODE(size_t length2 =) paint.breakText(text, length, width, &mm); |
+ SkASSERT(length2 == length); |
+ SkASSERT(mm == width); |
+} |
+ |
static const struct { |
const char* fName; |
uint32_t fFlags; |
@@ -74,6 +109,8 @@ |
TextSpeedView() { |
fHints = 0; |
fClickX = 0; |
+ |
+ test_breakText(); |
} |
protected: |