Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / content / test / gpu / gpu_tests / memory.py
index b56f737..dbb111f 100644 (file)
@@ -2,15 +2,16 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 import memory_expectations
+import page_sets
 
-from telemetry import test
+from telemetry import benchmark
 from telemetry.page import page_test
-from telemetry.core.timeline import counter
-from telemetry.core.timeline import model
+from telemetry.timeline import counter
+from telemetry.timeline import model
 
-MEMORY_LIMIT_MB = 256
-SINGLE_TAB_LIMIT_MB = 128
-WIGGLE_ROOM_MB = 4
+MEMORY_LIMIT_MB = 192
+SINGLE_TAB_LIMIT_MB = 192
+WIGGLE_ROOM_MB = 12
 
 test_harness_script = r"""
   var domAutomationController = {};
@@ -33,7 +34,15 @@ test_harness_script = r"""
     // of iterations to settle).
 
     var rafCount = 0;
-    var totalRafCount = 8;
+
+    // Impl-side painting has changed the behavior of this test.
+    // Currently the background of the page shows up checkerboarded
+    // initially, causing the test to fail because the memory
+    // allocation is too low (no root layer). Temporarily increase the
+    // rAF count to 32 in order to make the test work reliably again.
+    // crbug.com/373098
+    // TODO(kbr): revert this change and put it back to 8 iterations.
+    var totalRafCount = 32;
 
     function pumpRAF() {
       if (rafCount == totalRafCount) {
@@ -54,7 +63,7 @@ test_harness_script = r"""
 """ % MEMORY_LIMIT_MB
 
 class _MemoryValidator(page_test.PageTest):
-  def ValidatePage(self, page, tab, results):
+  def ValidateAndMeasurePage(self, page, tab, results):
     timeline_data = tab.browser.StopTracing()
     timeline_model = model.TimelineModel(timeline_data)
     for process in timeline_model.GetAllProcesses():
@@ -63,10 +72,10 @@ class _MemoryValidator(page_test.PageTest):
         mb_used = counter.samples[-1] / 1048576
 
     if mb_used + WIGGLE_ROOM_MB < SINGLE_TAB_LIMIT_MB:
-      raise page_test.Failure('Memory allocation too low')
+      raise page_test.Failure(self._FormatException('low', mb_used))
 
     if mb_used - WIGGLE_ROOM_MB > MEMORY_LIMIT_MB:
-      raise page_test.Failure('Memory allocation too high')
+      raise page_test.Failure(self._FormatException('high', mb_used))
 
   def CustomizeBrowserOptions(self, options):
     options.AppendExtraBrowserArgs('--enable-logging')
@@ -74,13 +83,19 @@ class _MemoryValidator(page_test.PageTest):
         '--force-gpu-mem-available-mb=%s' % MEMORY_LIMIT_MB)
 
   def WillNavigateToPage(self, page, tab):
-    custom_categories = ['webkit.console', 'gpu']
+    # FIXME: Remove webkit.console when blink.console lands in chromium and the
+    # ref builds are updated. crbug.com/386847
+    custom_categories = ['webkit.console', 'blink.console', 'gpu']
     tab.browser.StartTracing(','.join(custom_categories), 60)
 
-class Memory(test.Test):
+  def _FormatException(self, low_or_high, mb_used):
+    return 'Memory allocation too %s (was %d MB, should be %d MB +/- %d MB)' % (
+      low_or_high, mb_used, SINGLE_TAB_LIMIT_MB, WIGGLE_ROOM_MB)
+
+class Memory(benchmark.Benchmark):
   """Tests GPU memory limits"""
   test = _MemoryValidator
-  page_set = 'page_sets/memory_tests.py'
+  page_set = page_sets.MemoryTestsPageSet
 
   def CreateExpectations(self, page_set):
     return memory_expectations.MemoryExpectations()