| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/json_value_serializer.h" | 13 #include "chrome/common/json_value_serializer.h" |
| 14 #include "chrome/test/automation/tab_proxy.h" | 14 #include "chrome/test/automation/tab_proxy.h" |
| 15 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 static const FilePath::CharType kStartFile[] = | 21 static const FilePath::CharType kStartFile[] = |
| 22 FILE_PATH_LITERAL("sunspider-driver.html"); | 22 FILE_PATH_LITERAL("sunspider-driver.html"); |
| 23 | 23 |
| 24 const wchar_t kRunSunSpiderTest[] = L"run-sunspider-test"; | 24 const wchar_t kRunSunSpider[] = L"run-sunspider"; |
| 25 | 25 |
| 26 class SunSpiderTest : public UITest { | 26 class SunSpiderTest : public UITest { |
| 27 public: | 27 public: |
| 28 typedef std::map<std::string, std::string> ResultsMap; | 28 typedef std::map<std::string, std::string> ResultsMap; |
| 29 | 29 |
| 30 SunSpiderTest() : reference_(false) { | 30 SunSpiderTest() : reference_(false) { |
| 31 dom_automation_enabled_ = true; | 31 dom_automation_enabled_ = true; |
| 32 show_window_ = true; | 32 show_window_ = true; |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 std::string total; | 133 std::string total; |
| 134 ASSERT_TRUE(GetTotal(tab, &total)); | 134 ASSERT_TRUE(GetTotal(tab, &total)); |
| 135 | 135 |
| 136 ResultsMap results; | 136 ResultsMap results; |
| 137 ASSERT_TRUE(GetResults(tab, &results)); | 137 ASSERT_TRUE(GetResults(tab, &results)); |
| 138 | 138 |
| 139 std::string trace_name = reference_ ? "t_ref" : "t"; | 139 std::string trace_name = reference_ ? "t_ref" : "t"; |
| 140 | 140 |
| 141 PrintResultMeanAndError("total", "", trace_name, total, "ms", true); | 141 PrintResultMeanAndError("total", "", trace_name, total, "ms", true); |
| 142 | 142 |
| 143 ResultsMap::iterator it = results.begin(); | 143 ResultsMap::const_iterator it = results.begin(); |
| 144 for (; it != results.end(); ++it) | 144 for (; it != results.end(); ++it) |
| 145 PrintResultList(it->first, "", trace_name, it->second, "ms", false); | 145 PrintResultList(it->first, "", trace_name, it->second, "ms", false); |
| 146 } | 146 } |
| 147 | 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(SunSpiderTest); | 148 DISALLOW_COPY_AND_ASSIGN(SunSpiderTest); |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 class SunSpiderReferenceTest : public SunSpiderTest { | 151 class SunSpiderReferenceTest : public SunSpiderTest { |
| 152 public: | 152 public: |
| 153 SunSpiderReferenceTest() : SunSpiderTest() { | 153 SunSpiderReferenceTest() : SunSpiderTest() { |
| 154 reference_ = true; | 154 reference_ = true; |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Override the browser directory that is used by UITest::SetUp to cause it | 157 // Override the browser directory that is used by UITest::SetUp to cause it |
| 158 // to use the reference build instead. | 158 // to use the reference build instead. |
| 159 void SetUp() { | 159 void SetUp() { |
| 160 FilePath dir; | 160 FilePath dir; |
| 161 PathService::Get(chrome::DIR_TEST_TOOLS, &dir); | 161 PathService::Get(chrome::DIR_TEST_TOOLS, &dir); |
| 162 dir = dir.AppendASCII("reference_build"); | 162 dir = dir.AppendASCII("reference_build"); |
| 163 dir = dir.AppendASCII("chrome"); | 163 dir = dir.AppendASCII("chrome"); |
| 164 browser_directory_ = dir.ToWStringHack(); | 164 browser_directory_ = dir.ToWStringHack(); |
| 165 UITest::SetUp(); | 165 UITest::SetUp(); |
| 166 } | 166 } |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 } // namespace | 169 } // namespace |
| 170 | 170 |
| 171 TEST_F(SunSpiderTest, Perf) { | 171 TEST_F(SunSpiderTest, Perf) { |
| 172 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunSunSpiderTest)) | 172 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunSunSpider)) |
| 173 return; | 173 return; |
| 174 | 174 |
| 175 RunTest(); | 175 RunTest(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 TEST_F(SunSpiderReferenceTest, Perf) { | 178 TEST_F(SunSpiderReferenceTest, Perf) { |
| 179 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunSunSpiderTest)) | 179 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunSunSpider)) |
| 180 return; | 180 return; |
| 181 | 181 |
| 182 RunTest(); | 182 RunTest(); |
| 183 } | 183 } |
| OLD | NEW |