Ensure that Slerp returns a non-inf for opposing vectors.

In the case where the given vectors are opposite of each other, we
get a 0 denominator which causes inf/nan values which later down
the pipeline can result in CHECKs since the layer transform would have
nans as well.

R=vollick
BUG=506543

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

Cr-Commit-Position: refs/heads/master@{#337881}
diff --git a/ui/gfx/transform_util_unittest.cc b/ui/gfx/transform_util_unittest.cc
index 404833c..02bf46a4 100644
--- a/ui/gfx/transform_util_unittest.cc
+++ b/ui/gfx/transform_util_unittest.cc
@@ -192,5 +192,18 @@
   EXPECT_EQ(Point(-11, -20).ToString(), point.ToString());
 }
 
+TEST(TransformUtilTest, BlendOppositeQuaternions) {
+  DecomposedTransform first;
+  DecomposedTransform second;
+  second.quaternion[3] = -second.quaternion[3];
+
+  DecomposedTransform result;
+  BlendDecomposedTransforms(&result, first, second, 0.25);
+  for (size_t i = 0; i < 4; ++i) {
+    EXPECT_TRUE(std::isfinite(result.quaternion[i]));
+    EXPECT_FALSE(std::isnan(result.quaternion[i]));
+  }
+}
+
 }  // namespace
 }  // namespace gfx