change setA/setB labels if viewing actuals vs expectations
authorepoger <epoger@google.com>
Tue, 12 Aug 2014 15:29:05 +0000 (08:29 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 12 Aug 2014 15:29:05 +0000 (08:29 -0700)
NOTRY=true
R=rmistry@google.com

Author: epoger@google.com

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

gm/rebaseline_server/compare_rendered_pictures.py
gm/rebaseline_server/compare_rendered_pictures_test.py
gm/rebaseline_server/static/live-view.html
gm/rebaseline_server/testdata/outputs/expected/compare_rendered_pictures_test.CompareRenderedPicturesTest.test_endToEnd/compare_rendered_pictures.json
gm/rebaseline_server/testdata/outputs/expected/compare_rendered_pictures_test.CompareRenderedPicturesTest.test_repo_url/compare_rendered_pictures.json

index 1207979f535d39f80431197d83d39bbff2601302..5b5a12973a398c3806dbaba3fbf26db68a4dbe16 100755 (executable)
@@ -78,7 +78,7 @@ class RenderedPicturesComparisons(results.BaseComparisons):
                setA_section, setB_section,
                image_diff_db,
                image_base_gs_url=DEFAULT_IMAGE_BASE_GS_URL, diff_base_url=None,
-               setA_label='setA', setB_label='setB',
+               setA_label=None, setB_label=None,
                gs=None, truncate_results=False, prefetch_only=False,
                download_all_images=False):
     """Constructor: downloads images and generates diffs.
@@ -108,8 +108,10 @@ class RenderedPicturesComparisons(results.BaseComparisons):
       diff_base_url: base URL within which the client should look for diff
           images; if not specified, defaults to a "file:///" URL representation
           of image_diff_db's storage_root
-      setA_label: description to use for results in setA
-      setB_label: description to use for results in setB
+      setA_label: description to use for results in setA; if None, will be
+          set to a reasonable default
+      setB_label: description to use for results in setB; if None, will be
+          set to a reasonable default
       gs: instance of GSUtils object we can use to download summary files
       truncate_results: FOR MANUAL TESTING: if True, truncate the set of images
           we process, to speed up testing.
@@ -128,13 +130,20 @@ class RenderedPicturesComparisons(results.BaseComparisons):
     self._diff_base_url = (
         diff_base_url or
         url_utils.create_filepath_url(image_diff_db.storage_root))
-    self._setA_label = setA_label
-    self._setB_label = setB_label
     self._gs = gs
     self.truncate_results = truncate_results
     self._prefetch_only = prefetch_only
     self._download_all_images = download_all_images
 
+    # If we are comparing two different section types, we can use those
+    # as the default labels for setA and setB.
+    if setA_section != setB_section:
+      self._setA_label = setA_label or setA_section
+      self._setB_label = setB_label or setB_section
+    else:
+      self._setA_label = setA_label or 'setA'
+      self._setB_label = setB_label or 'setB'
+
     tempdir = tempfile.mkdtemp()
     try:
       setA_root = os.path.join(tempdir, 'setA')
index e761c8a5c2dd37defaa8855e1eed75b8f0892606..6a057d29429c76967cf0d1e8744b4588fb7ad2f4 100755 (executable)
@@ -40,30 +40,29 @@ class CompareRenderedPicturesTest(base_unittest.TestCase):
   def test_endToEnd(self):
     """Generate two sets of SKPs, run render_pictures over both, and compare
     the results."""
-    setA_label = 'before_patch'
-    setB_label = 'after_patch'
+    setA_subdir = 'before_patch'
+    setB_subdir = 'after_patch'
     self._generate_skps_and_run_render_pictures(
-        subdir=setA_label, skpdict={
+        subdir=setA_subdir, skpdict={
             'changed.skp': 200,
             'unchanged.skp': 100,
             'only-in-before.skp': 128,
         })
     self._generate_skps_and_run_render_pictures(
-        subdir=setB_label, skpdict={
+        subdir=setB_subdir, skpdict={
             'changed.skp': 201,
             'unchanged.skp': 100,
             'only-in-after.skp': 128,
         })
 
     results_obj = compare_rendered_pictures.RenderedPicturesComparisons(
-        setA_dirs=[os.path.join(self.temp_dir, setA_label)],
-        setB_dirs=[os.path.join(self.temp_dir, setB_label)],
+        setA_dirs=[os.path.join(self.temp_dir, setA_subdir)],
+        setB_dirs=[os.path.join(self.temp_dir, setB_subdir)],
         setA_section=gm_json.JSONKEY_ACTUALRESULTS,
         setB_section=gm_json.JSONKEY_ACTUALRESULTS,
         image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir),
         image_base_gs_url='gs://fakebucket/fake/path',
-        diff_base_url='/static/generated-images',
-        setA_label=setA_label, setB_label=setB_label)
+        diff_base_url='/static/generated-images')
     results_obj.get_timestamp = mock_get_timestamp
 
     gm_json.WriteToFile(
@@ -81,8 +80,7 @@ class CompareRenderedPicturesTest(base_unittest.TestCase):
         setB_section=gm_json.JSONKEY_ACTUALRESULTS,
         image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir),
         image_base_gs_url='gs://fakebucket/fake/path',
-        diff_base_url='/static/generated-images',
-        setA_label='setA', setB_label='setB')
+        diff_base_url='/static/generated-images')
     results_obj.get_timestamp = mock_get_timestamp
 
     gm_json.WriteToFile(
index 2f8241e0473896e96ef829150d6af9cd58666e31..cb503784f7e9ab3f7d3409a4ed133733500927ea 100644 (file)
             <a ng-class="'sort-' + sortedByColumnsCls(constants.KEY__IMAGEPAIRS__IMAGE_A_URL)"
                ng-click="sortResultsBy('none', constants.KEY__IMAGEPAIRS__IMAGE_A_URL)"
                href=""
+               title="setA: '{{setASection}}' within {{setADir}}"
                class="sortable-header">
                    {{imageSets[constants.KEY__IMAGESETS__SET__IMAGE_A][constants.KEY__IMAGESETS__FIELD__DESCRIPTION]}}
             </a>
             <a ng-class="'sort-' + sortedByColumnsCls(constants.KEY__IMAGEPAIRS__IMAGE_B_URL)"
                ng-click="sortResultsBy('none', constants.KEY__IMAGEPAIRS__IMAGE_B_URL)"
                href=""
+               title="setB: '{{setBSection}}' within {{setBDir}}"
                class="sortable-header">
                   {{imageSets[constants.KEY__IMAGESETS__SET__IMAGE_B][constants.KEY__IMAGESETS__FIELD__DESCRIPTION]}}
             </a>
index 4eb963b06f16fbf4a9e401dbd0ce12d9b0519bf2..8cfdbe60117574c036012857914a1ad0c45a08bf 100644 (file)
     }, 
     "imageA": {
       "baseUrl": "http://storage.cloud.google.com/fakebucket/fake/path", 
-      "description": "before_patch"
+      "description": "setA"
     }, 
     "imageB": {
       "baseUrl": "http://storage.cloud.google.com/fakebucket/fake/path", 
-      "description": "after_patch"
+      "description": "setB"
     }, 
     "whiteDiffs": {
       "baseUrl": "/static/generated-images/whitediffs", 
index 8cfdbe60117574c036012857914a1ad0c45a08bf..da517c9da734f3e1250e5ffa0b02778fa89cdd84 100644 (file)
     }, 
     "imageA": {
       "baseUrl": "http://storage.cloud.google.com/fakebucket/fake/path", 
-      "description": "setA"
+      "description": "expected-results"
     }, 
     "imageB": {
       "baseUrl": "http://storage.cloud.google.com/fakebucket/fake/path", 
-      "description": "setB"
+      "description": "actual-results"
     }, 
     "whiteDiffs": {
       "baseUrl": "/static/generated-images/whitediffs",