OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 /* Description: | 8 /* Description: |
9 * This test defines a series of elementatry test steps that perform | 9 * This test defines a series of elementatry test steps that perform |
10 * a single or a small group of canvas API calls. Each test step is | 10 * a single or a small group of canvas API calls. Each test step is |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 REPORTER_ASSERT(reporter, info == info2); | 876 REPORTER_ASSERT(reporter, info == info2); |
877 for (int y = 0; y < info.height(); ++y) { | 877 for (int y = 0; y < info.height(); ++y) { |
878 for (int x = 0; x < info.width(); ++x) { | 878 for (int x = 0; x < info.width(); ++x) { |
879 REPORTER_ASSERT(reporter, 0 == addr[x]); | 879 REPORTER_ASSERT(reporter, 0 == addr[x]); |
880 } | 880 } |
881 addr = (const SkPMColor*)((const char*)addr + rowBytes); | 881 addr = (const SkPMColor*)((const char*)addr + rowBytes); |
882 } | 882 } |
883 SkDELETE(canvas); | 883 SkDELETE(canvas); |
884 | 884 |
885 // now try a deliberately bad info | 885 // now try a deliberately bad info |
886 info.fWidth = -1; | 886 info = info.makeWH(-1, info.height()); |
887 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); | 887 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); |
888 | 888 |
889 // too big | 889 // too big |
890 info.fWidth = 1 << 30; | 890 info = info.makeWH(1 << 30, 1 << 30); |
891 info.fHeight = 1 << 30; | |
892 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); | 891 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); |
893 | 892 |
894 // not a valid pixel type | 893 // not a valid pixel type |
895 info.fWidth = info.fHeight = 10; | 894 info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType()); |
896 info.fColorType = kUnknown_SkColorType; | |
897 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); | 895 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); |
898 | 896 |
899 // We should succeed with a zero-sized valid info | 897 // We should succeed with a zero-sized valid info |
900 info = SkImageInfo::MakeN32Premul(0, 0); | 898 info = SkImageInfo::MakeN32Premul(0, 0); |
901 canvas = SkCanvas::NewRaster(info); | 899 canvas = SkCanvas::NewRaster(info); |
902 REPORTER_ASSERT(reporter, canvas); | 900 REPORTER_ASSERT(reporter, canvas); |
903 SkDELETE(canvas); | 901 SkDELETE(canvas); |
904 } | 902 } |
905 | 903 |
906 DEF_TEST(Canvas, reporter) { | 904 DEF_TEST(Canvas, reporter) { |
907 // Init global here because bitmap pixels cannot be alocated during | 905 // Init global here because bitmap pixels cannot be alocated during |
908 // static initialization | 906 // static initialization |
909 kTestBitmap = testBitmap(); | 907 kTestBitmap = testBitmap(); |
910 | 908 |
911 for (int testStep = 0; testStep < testStepArray().count(); testStep++) { | 909 for (int testStep = 0; testStep < testStepArray().count(); testStep++) { |
912 TestOverrideStateConsistency(reporter, testStepArray()[testStep]); | 910 TestOverrideStateConsistency(reporter, testStepArray()[testStep]); |
913 SkPictureTester::TestPictureFlattenedObjectReuse(reporter, | 911 SkPictureTester::TestPictureFlattenedObjectReuse(reporter, |
914 testStepArray()[testStep], 0); | 912 testStepArray()[testStep], 0); |
915 if (testStepArray()[testStep]->enablePdfTesting()) { | 913 if (testStepArray()[testStep]->enablePdfTesting()) { |
916 TestPdfDevice(reporter, testStepArray()[testStep]); | 914 TestPdfDevice(reporter, testStepArray()[testStep]); |
917 } | 915 } |
918 } | 916 } |
919 | 917 |
920 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) | 918 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) |
921 kTestBitmap.reset(); | 919 kTestBitmap.reset(); |
922 | 920 |
923 test_newraster(reporter); | 921 test_newraster(reporter); |
924 } | 922 } |
OLD | NEW |