Add MotionMark to Chrome Health

Bug: chromium:1286916
Change-Id: I9b35ed6f0e312b13d31fb1a041eed1554519d86d
Reviewed-on: https://chromium-review.googlesource.com/c/catapult/+/3401478
Reviewed-by: John Chen <johnchen@chromium.org>
Commit-Queue: Ryan Heise <heiserya@google.com>
diff --git a/dashboard/dashboard/pinpoint/models/results2.py b/dashboard/dashboard/pinpoint/models/results2.py
index 1ad0064..2a6579f 100644
--- a/dashboard/dashboard/pinpoint/models/results2.py
+++ b/dashboard/dashboard/pinpoint/models/results2.py
@@ -55,7 +55,10 @@
         ("speedometer2", "Vanilla_ES2015_Babel_Webpack_TodoMVC"),
     "Vanilla-ES2015-TodoMVC": ("speedometer2", "Vanilla_ES2015_TodoMVC"),
     "VanillaJS-TodoMVC": ("speedometer2", "VanillaJS_TodoMVC"),
-    "VueJS-TodoMVC": ("speedometer2", "VueJS_TodoMVC")
+    "VueJS-TodoMVC": ("speedometer2", "VueJS_TodoMVC"),
+
+    # MotionMark
+    "motionmark": ("motionmark", "motionmark")
 }
 
 _PROJECT_ID = 'chromeperf'
@@ -309,6 +312,7 @@
   measures = {}
   measures["core_web_vitals"] = {}
   measures["speedometer2"] = {}
+  measures["motionmark"] = {}
   return measures
 
 
diff --git a/dashboard/dashboard/pinpoint/models/results2_test.py b/dashboard/dashboard/pinpoint/models/results2_test.py
index 1a05125..437c690 100644
--- a/dashboard/dashboard/pinpoint/models/results2_test.py
+++ b/dashboard/dashboard/pinpoint/models/results2_test.py
@@ -431,7 +431,8 @@
                 'largestContentfulPaint': 42.0,
                 'overallCumulativeLayoutShift': 22.0
             },
-            'speedometer2': {}
+            'speedometer2': {},
+            'motionmark': {}
         },
         'run_id': 'fake_job_id'
     }, {
@@ -468,7 +469,8 @@
                 'largestContentfulPaint': 42.0,
                 'overallCumulativeLayoutShift': 22.0
             },
-            'speedometer2': {}
+            'speedometer2': {},
+            'motionmark': {}
         },
         'run_id': 'fake_job_id'
     }]
@@ -554,7 +556,8 @@
                 'Vanilla_ES2015_TodoMVC': 14,
                 'VanillaJS_TodoMVC': 15,
                 'VueJS_TodoMVC': 16
-            }
+            },
+            'motionmark': {}
         },
         'run_id': 'fake_job_id'
     }, {
@@ -604,7 +607,8 @@
                 'Vanilla_ES2015_TodoMVC': 14,
                 'VanillaJS_TodoMVC': 15,
                 'VueJS_TodoMVC': 16
-            }
+            },
+            'motionmark': {}
         },
         'run_id': 'fake_job_id'
     }]
@@ -613,6 +617,95 @@
     self.maxDiff = None
     self.assertItemsEqual(mock_bqinsert.call_args_list[0][0][3], expected_rows)
 
+  @mock.patch.object(results2, '_GcsFileStream', mock.MagicMock())
+  @mock.patch.object(results2, '_InsertBQRows')
+  @mock.patch.object(results2.render_histograms_viewer,
+                     'RenderHistogramsViewer')
+  @mock.patch.object(results2, '_JsonFromExecution')
+  @mock.patch.object(swarming, 'Swarming')
+  @mock.patch.object(commit.Commit, 'GetOrCacheCommitInfo')
+  def testTypeDispatch_PushBQ_CH_MotionMark(self, mock_commit_info,
+                                            mock_swarming, mock_json,
+                                            mock_render, mock_bqinsert):
+    expected_histogram_set = histogram_set.HistogramSet([
+        _CreateHistogram('motionmark', 1),
+    ])
+    job = _SetupBQTest(mock_commit_info, mock_swarming, mock_render, mock_json,
+                       expected_histogram_set, set_device_os=False)
+
+    expected_rows = [{
+        'job_start_time': _TEST_START_TIME_STR,
+        'batch_id': 'fake_batch_id',
+        'dims': {
+            'device': {
+                'cfg': 'fake_configuration',
+                'swarming_bot_id': 'fake_id',
+                'os': ['base_os']
+            },
+            'test_info': {
+                'story': 'fake_story',
+                'benchmark': 'fake_benchmark'
+            },
+            'pairing': {
+                'replica': 0,
+                'variant': 0
+            },
+            'checkout': {
+                'repo': 'fakerepo',
+                'git_hash': 'fakehashA',
+                'commit_position': 437745,
+                'commit_created': '2021-12-08 00:00:00.000000',
+                'branch': 'refs/heads/main'
+            }
+        },
+        'measures': {
+            'core_web_vitals': {},
+            'speedometer2': {},
+            'motionmark': {
+                'motionmark': 1
+            }
+        },
+        'run_id': 'fake_job_id'
+    }, {
+        'job_start_time': _TEST_START_TIME_STR,
+        'batch_id': 'fake_batch_id',
+        'dims': {
+            'device': {
+                'cfg': 'fake_configuration',
+                'swarming_bot_id': 'fake_id',
+                'os': ['base_os']
+            },
+            'test_info': {
+                'story': 'fake_story',
+                'benchmark': 'fake_benchmark'
+            },
+            'pairing': {
+                'replica': 0,
+                'variant': 1
+            },
+            'checkout': {
+                'patch_gerrit_revision': 'fake_patch_set',
+                'commit_position': 437745,
+                'commit_created': '2021-12-08 00:00:00.000000',
+                'patch_gerrit_change': 'fake_patch_issue',
+                'repo': 'fakeRepo',
+                'branch': 'refs/heads/main',
+                'git_hash': 'fakehashB'
+            }
+        },
+        'measures': {
+            'core_web_vitals': {},
+            'speedometer2': {},
+            'motionmark': {
+                'motionmark': 1
+            }
+        },
+        'run_id': 'fake_job_id'
+    }]
+
+    results2.GenerateResults2(job)
+    self.maxDiff = None
+    self.assertItemsEqual(mock_bqinsert.call_args_list[0][0][3], expected_rows)
 
   @mock.patch.object(results2, '_GcsFileStream', mock.MagicMock())
   @mock.patch.object(results2, '_InsertBQRows')
diff --git a/dashboard/dashboard/proto/pinpoint_chrome_health_results.proto b/dashboard/dashboard/proto/pinpoint_chrome_health_results.proto
index 29dff35..15ca61e 100644
--- a/dashboard/dashboard/proto/pinpoint_chrome_health_results.proto
+++ b/dashboard/dashboard/proto/pinpoint_chrome_health_results.proto
@@ -36,9 +36,14 @@
   float RunsPerMinute = 17;
 }
 
+message MotionMark {
+  float motionmark = 1;
+}
+
 message Measures {
   CoreWebVitals core_web_vitals = 1;
   Speedometer2 speedometer2 = 2;
+  MotionMark motionmark = 3;
 }
 
 // Represents a row in a BigQuery table.