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 "chrome/test/base/uma_histogram_helper.h" | 5 #include "chrome/test/base/chrome_histogram_tester.h" |
6 #include "chrome/test/nacl/nacl_browsertest_util.h" | 6 #include "chrome/test/nacl/nacl_browsertest_util.h" |
7 #include "components/nacl/browser/nacl_browser.h" | 7 #include "components/nacl/browser/nacl_browser.h" |
8 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 8 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
9 #include "ppapi/c/private/ppb_nacl_private.h" | 9 #include "ppapi/c/private/ppb_nacl_private.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, { | 13 NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, { |
| 14 ChromeHistogramTester histograms; |
14 // Load a NaCl module to generate UMA data. | 15 // Load a NaCl module to generate UMA data. |
15 RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); | 16 RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); |
16 | 17 |
17 // Make sure histograms from child processes have been accumulated in the | 18 // Make sure histograms from child processes have been accumulated in the |
18 // browser brocess. | 19 // browser brocess. |
19 UMAHistogramHelper histograms; | 20 histograms.FetchTestingSnapshot(); |
20 histograms.Fetch(); | |
21 | 21 |
22 // Did the plugin report success? | 22 // Did the plugin report success? |
23 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin", | 23 histograms.ExpectUniqueSample("NaCl.LoadStatus.Plugin", |
24 PP_NACL_ERROR_LOAD_SUCCESS, 1); | 24 PP_NACL_ERROR_LOAD_SUCCESS, 1); |
25 | 25 |
26 // Did the sel_ldr report success? | 26 // Did the sel_ldr report success? |
27 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", | 27 histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", |
28 LOAD_OK, 1); | 28 LOAD_OK, 1); |
29 | 29 |
30 // Check validation cache usage: | 30 // Check validation cache usage: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 class NaClBrowserTestVcacheExtension: | 81 class NaClBrowserTestVcacheExtension: |
82 public NaClBrowserTestNewlibExtension { | 82 public NaClBrowserTestNewlibExtension { |
83 public: | 83 public: |
84 virtual base::FilePath::StringType Variant() OVERRIDE { | 84 virtual base::FilePath::StringType Variant() OVERRIDE { |
85 return FILE_PATH_LITERAL("extension_vcache_test/newlib"); | 85 return FILE_PATH_LITERAL("extension_vcache_test/newlib"); |
86 } | 86 } |
87 }; | 87 }; |
88 | 88 |
89 IN_PROC_BROWSER_TEST_F(NaClBrowserTestVcacheExtension, | 89 IN_PROC_BROWSER_TEST_F(NaClBrowserTestVcacheExtension, |
90 ValidationCacheOfMainNexe) { | 90 ValidationCacheOfMainNexe) { |
| 91 ChromeHistogramTester histograms; |
91 // Hardcoded extension AppID that corresponds to the hardcoded | 92 // Hardcoded extension AppID that corresponds to the hardcoded |
92 // public key in the manifest.json file. We need to load the extension | 93 // public key in the manifest.json file. We need to load the extension |
93 // nexe from the same origin, so we can't just try to load the extension | 94 // nexe from the same origin, so we can't just try to load the extension |
94 // nexe as a mime-type handler from a non-extension URL. | 95 // nexe as a mime-type handler from a non-extension URL. |
95 base::FilePath::StringType full_url = | 96 base::FilePath::StringType full_url = |
96 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/") | 97 FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/") |
97 FILE_PATH_LITERAL("extension_validation_cache.html"); | 98 FILE_PATH_LITERAL("extension_validation_cache.html"); |
98 RunNaClIntegrationTest(full_url, true); | 99 RunNaClIntegrationTest(full_url, true); |
99 | 100 |
100 // Make sure histograms from child processes have been accumulated in the | 101 // Make sure histograms from child processes have been accumulated in the |
101 // browser brocess. | 102 // browser brocess. |
102 UMAHistogramHelper histograms; | 103 histograms.FetchTestingSnapshot(); |
103 histograms.Fetch(); | |
104 // Should have received 2 validation queries (one for IRT and one for NEXE), | 104 // Should have received 2 validation queries (one for IRT and one for NEXE), |
105 // and responded with a miss. | 105 // and responded with a miss. |
106 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", | 106 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
107 nacl::NaClBrowser::CACHE_MISS, 2); | 107 nacl::NaClBrowser::CACHE_MISS, 2); |
108 // TOTAL should then be 2 queries so far. | 108 // TOTAL should then be 2 queries so far. |
109 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 2); | 109 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 2); |
110 // Should have received a cache setting afterwards for IRT and nexe. | 110 // Should have received a cache setting afterwards for IRT and nexe. |
111 histograms.ExpectBucketCount("NaCl.ValidationCache.Set", | 111 histograms.ExpectBucketCount("NaCl.ValidationCache.Set", |
112 nacl::NaClBrowser::CACHE_HIT, 2); | 112 nacl::NaClBrowser::CACHE_HIT, 2); |
113 | 113 |
114 // Load it again to hit the cache. | 114 // Load it again to hit the cache. |
115 RunNaClIntegrationTest(full_url, true); | 115 RunNaClIntegrationTest(full_url, true); |
116 histograms.Fetch(); | 116 histograms.FetchTestingSnapshot(); |
117 // Should have received 2 more validation queries later (IRT and NEXE), | 117 // Should have received 2 more validation queries later (IRT and NEXE), |
118 // and responded with a hit. | 118 // and responded with a hit. |
119 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", | 119 histograms.ExpectBucketCount("NaCl.ValidationCache.Query", |
120 nacl::NaClBrowser::CACHE_HIT, 2); | 120 nacl::NaClBrowser::CACHE_HIT, 2); |
121 // TOTAL should then be 4 queries now. | 121 // TOTAL should then be 4 queries now. |
122 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4); | 122 histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4); |
123 // Still only 2 settings. | 123 // Still only 2 settings. |
124 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2); | 124 histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2); |
125 } | 125 } |
126 | 126 |
127 // Test that validation for the 2 PNaCl translator nexes can be cached. | 127 // Test that validation for the 2 PNaCl translator nexes can be cached. |
128 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, | 128 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, |
129 ValidationCacheOfTranslatorNexes) { | 129 ValidationCacheOfTranslatorNexes) { |
| 130 ChromeHistogramTester histograms; |
130 // Run a load test w/ one pexe cache identity. | 131 // Run a load test w/ one pexe cache identity. |
131 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); | 132 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); |
132 | 133 |
133 UMAHistogramHelper histograms; | 134 histograms.FetchTestingSnapshot(); |
134 histograms.Fetch(); | |
135 // Should have received 3 validation queries: | 135 // Should have received 3 validation queries: |
136 // - One for IRT for actual application | 136 // - One for IRT for actual application |
137 // - Two for two translator nexes | 137 // - Two for two translator nexes |
138 // The translators don't currently use the IRT, so there is no IRT cache | 138 // The translators don't currently use the IRT, so there is no IRT cache |
139 // query for those two loads. The PNaCl main nexe comes from a | 139 // query for those two loads. The PNaCl main nexe comes from a |
140 // delete-on-close temp file, so it doesn't have a stable identity | 140 // delete-on-close temp file, so it doesn't have a stable identity |
141 // for validation caching. All three query results should be misses. | 141 // for validation caching. All three query results should be misses. |
142 histograms.ExpectUniqueSample("NaCl.ValidationCache.Query", | 142 histograms.ExpectUniqueSample("NaCl.ValidationCache.Query", |
143 nacl::NaClBrowser::CACHE_MISS, 3); | 143 nacl::NaClBrowser::CACHE_MISS, 3); |
144 // Should have received a cache setting afterwards for IRT and translators. | 144 // Should have received a cache setting afterwards for IRT and translators. |
(...skipping 14 matching lines...) Expand all Loading... |
159 // No extra cache settings. | 159 // No extra cache settings. |
160 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", | 160 histograms.ExpectUniqueSample("NaCl.ValidationCache.Set", |
161 nacl::NaClBrowser::CACHE_HIT, 3); | 161 nacl::NaClBrowser::CACHE_HIT, 3); |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) | 165 // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) |
166 // Test validation failures and crashes. | 166 // Test validation failures and crashes. |
167 | 167 |
168 } // namespace | 168 } // namespace |
OLD | NEW |