Run mash_content_unittests on bots

- Add mash_content_unittests that runs content_unittests under mash;
- Make FakeRenderWidgetHostViewAura only install delegate frame host
  when it is supported (i.e. RWHVAura has a valid |frame_sink_id_|);
- Early out a few of tests that do not work in mash;

And content_unittests still uses TestWindowTreeClientSetup since the
tests are happy with it and do not need test_ws.

Bug: 866942
Change-Id: I664470f0efba1f350a2ae22cb978e0f3f9b2d1f5
Reviewed-on: https://chromium-review.googlesource.com/1153768
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579836}
diff --git a/content/browser/frame_host/render_widget_host_view_guest_unittest.cc b/content/browser/frame_host/render_widget_host_view_guest_unittest.cc
index fa97ccf..4864b1b 100644
--- a/content/browser/frame_host/render_widget_host_view_guest_unittest.cc
+++ b/content/browser/frame_host/render_widget_host_view_guest_unittest.cc
@@ -198,6 +198,12 @@
 };
 
 TEST_F(RenderWidgetHostViewGuestSurfaceTest, TestGuestSurface) {
+  // Early out because RenderWidgetHostViewChildFrame::SendSurfaceInfoToEmbedder
+  // is no-op on mash and the test expects it call into FirstSurfaceActivation
+  // of BrowserPluginGuest.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   gfx::Size view_size(100, 100);
   gfx::Rect view_rect(view_size);
   float scale_factor = 1.f;
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
index 78c4e5f..2b13f71 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
@@ -498,6 +498,11 @@
   static void InstallDelegatedFrameHostClient(
       RenderWidgetHostViewAura* view,
       std::unique_ptr<DelegatedFrameHostClient> delegated_frame_host_client) {
+    // Follow RWHVAura code that does not create DelegateFrameHost when there is
+    // no valid frame sink id.
+    if (!view->frame_sink_id_.is_valid())
+      return;
+
     view->delegated_frame_host_client_ = std::move(delegated_frame_host_client);
     const bool enable_viz = features::IsVizDisplayCompositorEnabled();
     view->delegated_frame_host_ = nullptr;
@@ -3441,6 +3446,10 @@
 // then the fallback is dropped.
 TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
        DropFallbackWhenHidden) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   view_->InitAsChild(nullptr);
   aura::client::ParentWindowWithContext(
       view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
@@ -3465,6 +3474,10 @@
 // This test verifies that the primary SurfaceId is populated on resize and
 // the fallback SurfaceId is populated in OnFirstSurfaceActivation.
 TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   view_->InitAsChild(nullptr);
   aura::client::ParentWindowWithContext(
       view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
@@ -3565,6 +3578,10 @@
 // RenderWidgetHostViewAuraTest.DiscardDelegatedFrame.
 TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
        DiscardDelegatedFrames) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   view_->InitAsChild(nullptr);
 
   size_t max_renderer_frames =
@@ -3701,6 +3718,10 @@
 }
 
 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   view_->InitAsChild(nullptr);
 
   size_t max_renderer_frames =
@@ -3771,6 +3792,10 @@
 // Test that changing the memory pressure should delete saved frames. This test
 // only applies to ChromeOS.
 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithMemoryPressure) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   view_->InitAsChild(nullptr);
 
   // The test logic below relies on having max_renderer_frames > 2.  By default,
@@ -5958,6 +5983,10 @@
 // visible we show blank.
 TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
        DropFallbackIfResizedWhileHidden) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   view_->InitAsChild(nullptr);
   aura::client::ParentWindowWithContext(
       view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
@@ -5977,6 +6006,10 @@
 // fallback SurfaceId has to be preserved.
 TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
        DontDropFallbackIfNotResizedWhileHidden) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   view_->InitAsChild(nullptr);
   aura::client::ParentWindowWithContext(
       view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
@@ -5995,6 +6028,10 @@
 // background color from the previous view to the new view.
 TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
        TakeFallbackContent) {
+  // Early out because DelegatedFrameHost is not used in mash.
+  if (!features::IsAshInBrowserProcess())
+    return;
+
   // Initialize the first view.
   view_->InitAsChild(nullptr);
   aura::client::ParentWindowWithContext(
diff --git a/testing/buildbot/chromium.chromiumos.json b/testing/buildbot/chromium.chromiumos.json
index 14cebf0..42f780a 100644
--- a/testing/buildbot/chromium.chromiumos.json
+++ b/testing/buildbot/chromium.chromiumos.json
@@ -492,6 +492,16 @@
       },
       {
         "args": [
+          "--enable-features=Mash"
+        ],
+        "name": "mash_content_unittests",
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "content_unittests"
+      },
+      {
+        "args": [
           "--enable-features=VizDisplayCompositor"
         ],
         "name": "viz_content_unittests",
@@ -1104,6 +1114,16 @@
       },
       {
         "args": [
+          "--enable-features=Mash"
+        ],
+        "name": "mash_content_unittests",
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "content_unittests"
+      },
+      {
+        "args": [
           "--enable-features=VizDisplayCompositor"
         ],
         "name": "viz_content_unittests",
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json
index c6b0b26..d9da105 100644
--- a/testing/buildbot/chromium.fyi.json
+++ b/testing/buildbot/chromium.fyi.json
@@ -1436,6 +1436,16 @@
       },
       {
         "args": [
+          "--enable-features=Mash"
+        ],
+        "name": "mash_content_unittests",
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "content_unittests"
+      },
+      {
+        "args": [
           "--enable-features=VizDisplayCompositor"
         ],
         "name": "viz_content_unittests",
diff --git a/testing/buildbot/chromium.memory.json b/testing/buildbot/chromium.memory.json
index 0d7954c..e1e6cd2 100644
--- a/testing/buildbot/chromium.memory.json
+++ b/testing/buildbot/chromium.memory.json
@@ -4405,6 +4405,16 @@
       },
       {
         "args": [
+          "--enable-features=Mash"
+        ],
+        "name": "mash_content_unittests",
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "content_unittests"
+      },
+      {
+        "args": [
           "--enable-features=VizDisplayCompositor"
         ],
         "name": "viz_content_unittests",
@@ -5016,6 +5026,16 @@
       },
       {
         "args": [
+          "--enable-features=Mash"
+        ],
+        "name": "mash_content_unittests",
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "content_unittests"
+      },
+      {
+        "args": [
           "--enable-features=VizDisplayCompositor"
         ],
         "name": "viz_content_unittests",
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl
index e900605..3c2f653 100644
--- a/testing/buildbot/test_suites.pyl
+++ b/testing/buildbot/test_suites.pyl
@@ -1660,6 +1660,12 @@
         'shards': 10,
       },
     },
+    'mash_content_unittests': {
+      'test': 'content_unittests',
+      'args': [
+        '--enable-features=Mash',
+      ],
+    },
   },
 
   'memory_infra_isolated_scripts': {