Add isolated text tests for MotionMark
[WebKit-https.git] / PerformanceTests / MotionMark / tests / text / design.js
1 /*
2  * Copyright (C) 2017 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 (function() {
26
27 // The MotionMark-based TextBenchmark should already be set to |window.benchmarkClass|
28 var TextBenchmark = window.benchmarkClass;
29 var TextTemplateBenchmark = Utilities.createSubclass(TextBenchmark,
30     function(options)
31     {
32         var dataset;
33         switch (options["corpus"]) {
34         case "latin":
35             dataset = [
36                 "σχέδιο",
37                 "umění",
38                 "suunnittelu",
39                 "design",
40                 "deseń",
41                 "искусство",
42                 "дизайн",
43                 "conception",
44                 "kunst",
45                 "konstruktion",
46                 "τέχνη",
47                 "diseño"
48             ];
49             break;
50         case "cjk":
51             dataset = [
52                 "设计",
53                 "디자인",
54                 "デザイン",
55                 "がいねん",
56                 "藝術",
57                 "养殖",
58                 "예술",
59                 "展開する",
60                 "발달",
61                 "技術",
62                 "驚き",
63                 "使吃惊",
64             ];
65             break;
66         case "arabic":
67             dataset = [
68                 {text: "تصميم", direction: "rtl"},
69                 "வடிவமைப்பு",
70                 "योजना",
71                 {text: "לְעַצֵב", direction: "rtl"},
72                 {text: "خلاق", direction: "rtl"},
73                 "ศิลปะ",
74                 "कौशल",
75                 {text: "אָמָנוּת", direction: "rtl"},
76                 "கலை",
77                 "ดีไซน์",
78                 "পরিকল্পনা",
79                 {text: "ډیزاین", direction: "rtl"},
80             ];
81             break;
82         }
83
84         dataset.forEach(function(entry, i) {
85             var td = document.getElementById("cell" + i);
86             if (typeof entry === 'string') {
87                 td.innerText = entry;
88             } else {
89                 td.innerText = entry.text;
90                 td.classList.add("rtl");
91             }
92         })
93
94         TextBenchmark.call(this, options);
95     }
96 );
97
98 window.benchmarkClass = TextTemplateBenchmark;
99
100 })();