OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/common/automation_constants.h" | 9 #include "chrome/common/automation_constants.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 return test_dir.AppendASCII("indexeddb"); | 56 return test_dir.AppendASCII("indexeddb"); |
57 } | 57 } |
58 | 58 |
59 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { | 59 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { |
60 return WaitUntilCookieValue(tab, test_url, "__done", | 60 return WaitUntilCookieValue(tab, test_url, "__done", |
61 TestTimeouts::large_test_timeout(), "1"); | 61 TestTimeouts::large_test_timeout(), "1"); |
62 } | 62 } |
63 | 63 |
64 bool GetResults(TabProxy* tab, ResultsMap* results) { | 64 bool GetResults(TabProxy* tab, ResultsMap* results) { |
65 std::wstring json_wide; | 65 std::wstring json_wide; |
66 bool succeeded = tab->ExecuteAndExtractString(L"", | 66 bool succeeded = tab->ExecuteAndExtractString( |
| 67 std::wstring(), |
67 L"window.domAutomationController.send(" | 68 L"window.domAutomationController.send(" |
68 L" JSON.stringify(automation.getResults()));", | 69 L" JSON.stringify(automation.getResults()));", |
69 &json_wide); | 70 &json_wide); |
70 | 71 |
71 EXPECT_TRUE(succeeded); | 72 EXPECT_TRUE(succeeded); |
72 if (!succeeded) | 73 if (!succeeded) |
73 return false; | 74 return false; |
74 | 75 |
75 std::string json = WideToUTF8(json_wide); | 76 std::string json = WideToUTF8(json_wide); |
76 return JsonDictionaryToMap(json, results); | 77 return JsonDictionaryToMap(json, results); |
77 } | 78 } |
78 | 79 |
79 void PrintResults(TabProxy* tab) { | 80 void PrintResults(TabProxy* tab) { |
80 ResultsMap results; | 81 ResultsMap results; |
81 ASSERT_TRUE(GetResults(tab, &results)); | 82 ASSERT_TRUE(GetResults(tab, &results)); |
82 | 83 |
83 std::string trace_name = reference_ ? "t_ref" : "t"; | 84 std::string trace_name = reference_ ? "t_ref" : "t"; |
84 | 85 |
85 ResultsMap::const_iterator it = results.begin(); | 86 ResultsMap::const_iterator it = results.begin(); |
86 for (; it != results.end(); ++it) | 87 for (; it != results.end(); ++it) |
87 perf_test::PrintResultList(it->first, "", trace_name, it->second, "ms", | 88 perf_test::PrintResultList( |
88 false); | 89 it->first, std::string(), trace_name, it->second, "ms", false); |
89 } | 90 } |
90 | 91 |
91 DISALLOW_COPY_AND_ASSIGN(IndexedDBTest); | 92 DISALLOW_COPY_AND_ASSIGN(IndexedDBTest); |
92 }; | 93 }; |
93 | 94 |
94 class IndexedDBReferenceTest : public IndexedDBTest { | 95 class IndexedDBReferenceTest : public IndexedDBTest { |
95 public: | 96 public: |
96 IndexedDBReferenceTest() : IndexedDBTest() { | 97 IndexedDBReferenceTest() : IndexedDBTest() { |
97 reference_ = true; | 98 reference_ = true; |
98 } | 99 } |
99 | 100 |
100 virtual void SetUp() { | 101 virtual void SetUp() { |
101 UseReferenceBuild(); | 102 UseReferenceBuild(); |
102 IndexedDBTest::SetUp(); | 103 IndexedDBTest::SetUp(); |
103 } | 104 } |
104 }; | 105 }; |
105 | 106 |
106 TEST_F(IndexedDBTest, Perf) { | 107 TEST_F(IndexedDBTest, Perf) { |
107 | 108 |
108 RunTest(); | 109 RunTest(); |
109 } | 110 } |
110 | 111 |
111 TEST_F(IndexedDBReferenceTest, Perf) { | 112 TEST_F(IndexedDBReferenceTest, Perf) { |
112 | 113 |
113 RunTest(); | 114 RunTest(); |
114 } | 115 } |
115 | 116 |
116 } // namespace | 117 } // namespace |
OLD | NEW |