Fixes for SkPictureShader.

Update comment in header to make it more clear that the picture
should be unaltered after creating the shader. We want our shaders
to be immutable, and this supports that.

Make the factory return NULL if the shader would have never drawn
anyway i.e. for a null picture or picture with no width/height.

Addresses comments I brought up in
https://codereview.chromium.org/221923007/#msg16.

BUG=skia:1976
R=reed@google.com, fmalita@chromium.org, robertphillips@google.com

Author: scroggo@google.com

Review URL: https://codereview.chromium.org/238253005

git-svn-id: http://skia.googlecode.com/svn/trunk@14288 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PictureShaderTest.cpp b/tests/PictureShaderTest.cpp
new file mode 100644
index 0000000..17ef5b5
--- /dev/null
+++ b/tests/PictureShaderTest.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkPicture.h"
+#include "SkPictureRecorder.h"
+#include "SkShader.h"
+#include "Test.h"
+
+// Test that attempting to create a picture shader with a NULL picture or
+// empty picture returns NULL.
+DEF_TEST(PictureShader_empty, reporter) {
+    SkShader* shader = SkShader::CreatePictureShader(NULL,
+            SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
+    REPORTER_ASSERT(reporter, NULL == shader);
+
+    SkPictureRecorder factory;
+    factory.beginRecording(0, 0, NULL, 0);
+    SkAutoTUnref<SkPicture> picture(factory.endRecording());
+    shader = SkShader::CreatePictureShader(picture.get(),
+            SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
+    REPORTER_ASSERT(reporter, NULL == shader);
+}