Implement WebKit::WebUnitTestSupport::createLayerTreeViewForTesting()

This provides an implementation WebKit::WebUnitTestSupport::createLayerTreeViewForTesting()
for webkit_unit_tests that want to instantiate compositing support and need initialization
to succeed but do not need to actually render anything. Critically, this sort of
view does not depend on any particular client or settings.

This appears to be a lot of code, but it's actually a bit of movement and very
little new code.  The primary movement is extracting most of the test class
cc/test/fake_web_graphics_context3d.h into cc/fake_web_graphics_context3d.h so
that it can be exported to other modules as a regular class. This is necessary
since webkit_unit_tests are in a different component and must use only the
normally exported parts of the cc library.  cc/test/test_web_graphics_context3d.h
has all of the extra bells and whistles and assertions for cc_unittests.

WebLayerTreeViewImplForTesting uses a very simple context and does not depend
on an external client at all.  This results in two subtle but very significant
properties (which are the point of this whole exercise) - the unit tests no longer
depend on WebLayerTreeViewClient or WebGraphicsContext3D at all.  The entire
notion of what the context type is now entirely hidden in the chromium side of
the codebase and can be swapped out for something else (like gpu::GLES2Interface)
without any further changes on the WebKit side.

After this patch, the only remaining caller of WebCompositorSupport::createLayerTreeView
in the WebKit tree is WebViewHost, which needs to instantiate a view that can
render pixels (using mesa) for DumpRenderTree.  I'll address that separately.

BUG=175383

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181817 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index c116d935..2c6eefc 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -28,11 +28,11 @@
 #include "cc/test/fake_output_surface.h"
 #include "cc/test/fake_proxy.h"
 #include "cc/test/fake_video_frame_provider.h"
-#include "cc/test/fake_web_graphics_context_3d.h"
 #include "cc/test/fake_web_scrollbar_theme_geometry.h"
 #include "cc/test/geometry_test_utils.h"
 #include "cc/test/layer_test_common.h"
 #include "cc/test/render_pass_test_common.h"
+#include "cc/test/test_web_graphics_context_3d.h"
 #include "cc/texture_draw_quad.h"
 #include "cc/texture_layer_impl.h"
 #include "cc/tile_draw_quad.h"
@@ -232,7 +232,7 @@
     bool m_reduceMemoryResult;
 };
 
-class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D {
+class TestWebGraphicsContext3DMakeCurrentFails : public TestWebGraphicsContext3D {
 public:
     virtual bool makeContextCurrent() { return false; }
 };
@@ -387,7 +387,7 @@
     m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
 
     // Initialization will fail here.
-    m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
+    m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TestWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
     m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
 
     setupScrollAndContentsLayers(gfx::Size(100, 100));
@@ -1717,7 +1717,7 @@
     expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScrollDelta);
 }
 
-class BlendStateTrackerContext: public FakeWebGraphicsContext3D {
+class BlendStateTrackerContext: public TestWebGraphicsContext3D {
 public:
     BlendStateTrackerContext() : m_blend(false) { }
 
@@ -2079,7 +2079,7 @@
 }
 
 
-class ReshapeTrackerContext: public FakeWebGraphicsContext3D {
+class ReshapeTrackerContext: public TestWebGraphicsContext3D {
 public:
     ReshapeTrackerContext() : m_reshapeCalled(false) { }
 
@@ -2124,7 +2124,7 @@
     m_hostImpl->didDrawAllLayers(frame);
 }
 
-class PartialSwapTrackerContext : public FakeWebGraphicsContext3D {
+class PartialSwapTrackerContext : public TestWebGraphicsContext3D {
 public:
     virtual void postSubBufferCHROMIUM(int x, int y, int width, int height)
     {
@@ -2268,7 +2268,7 @@
     }
 };
 
-class MockContext : public FakeWebGraphicsContext3D {
+class MockContext : public TestWebGraphicsContext3D {
 public:
     MOCK_METHOD1(useProgram, void(WebKit::WebGLId program));
     MOCK_METHOD5(uniform4f, void(WebKit::WGC3Dint location, WebKit::WGC3Dfloat x, WebKit::WGC3Dfloat y, WebKit::WGC3Dfloat z, WebKit::WGC3Dfloat w));
@@ -2426,7 +2426,7 @@
     Mock::VerifyAndClearExpectations(&mockContext);
 }
 
-class PartialSwapContext : public FakeWebGraphicsContext3D {
+class PartialSwapContext : public TestWebGraphicsContext3D {
 public:
     virtual WebKit::WebString getString(WebKit::WGC3Denum name)
     {
@@ -2557,16 +2557,16 @@
 }
 
 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use.
-class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D {
+class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D {
 public:
     TrackingWebGraphicsContext3D()
-        : FakeWebGraphicsContext3D()
+        : TestWebGraphicsContext3D()
         , m_numTextures(0)
     { }
 
     virtual WebKit::WebGLId createTexture() OVERRIDE
     {
-        WebKit::WebGLId id = FakeWebGraphicsContext3D::createTexture();
+        WebKit::WebGLId id = TestWebGraphicsContext3D::createTexture();
 
         m_textures[id] = true;
         ++m_numTextures;
@@ -2613,9 +2613,9 @@
 
 TEST_P(LayerTreeHostImplTest, layersFreeTextures)
 {
-    scoped_ptr<FakeWebGraphicsContext3D> context =
-            FakeWebGraphicsContext3D::Create();
-    FakeWebGraphicsContext3D* context3d = context.get();
+    scoped_ptr<TestWebGraphicsContext3D> context =
+            TestWebGraphicsContext3D::Create();
+    TestWebGraphicsContext3D* context3d = context.get();
     scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(
         context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
     m_hostImpl->initializeRenderer(outputSurface.Pass());
@@ -2661,7 +2661,7 @@
     EXPECT_EQ(0u, context3d->NumTextures());
 }
 
-class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D {
+class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D {
 public:
     MOCK_METHOD1(useProgram, void(WebKit::WebGLId program));
     MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei count, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset));
@@ -4044,7 +4044,7 @@
     {
         // Creates an output surface with a parent to use a delegating renderer.
         WebKit::WebGraphicsContext3D::Attributes attrs;
-        return FakeOutputSurface::CreateDelegating3d(FakeWebGraphicsContext3D::Create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
+        return FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
     }
 
     void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) {