| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/chrome/browser/net/metrics_network_client.h" | 5 #include "ios/chrome/browser/net/metrics_network_client.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 12 // Dummy client to be registered as underlying client for the | 16 // Dummy client to be registered as underlying client for the |
| 13 // MetricsNetworkClient. | 17 // MetricsNetworkClient. |
| 14 @interface MetricsMockClient : CRNForwardingNetworkClient | 18 @interface MetricsMockClient : CRNForwardingNetworkClient |
| 15 @end | 19 @end |
| 16 | 20 |
| 17 @implementation MetricsMockClient | 21 @implementation MetricsMockClient |
| 18 | 22 |
| 19 - (void)didFailWithNSErrorCode:(NSInteger)nsErrorCode | 23 - (void)didFailWithNSErrorCode:(NSInteger)nsErrorCode |
| 20 netErrorCode:(int)netErrorCode { | 24 netErrorCode:(int)netErrorCode { |
| 21 } | 25 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 netErrorCode:net_error]; | 67 netErrorCode:net_error]; |
| 64 // |net_error| is negative, the histogram reports the opposite value. | 68 // |net_error| is negative, the histogram reports the opposite value. |
| 65 histogram_tester_.ExpectUniqueSample(kHistogramName, -net_error, 1); | 69 histogram_tester_.ExpectUniqueSample(kHistogramName, -net_error, 1); |
| 66 } | 70 } |
| 67 | 71 |
| 68 TEST_F(MetricsNetworkClientTest, HistogramUpdatedOnSuccess) { | 72 TEST_F(MetricsNetworkClientTest, HistogramUpdatedOnSuccess) { |
| 69 VerifyNoSamples(); | 73 VerifyNoSamples(); |
| 70 [client_ didFinishLoading]; | 74 [client_ didFinishLoading]; |
| 71 histogram_tester_.ExpectUniqueSample(kHistogramName, -net::OK, 1); | 75 histogram_tester_.ExpectUniqueSample(kHistogramName, -net::OK, 1); |
| 72 } | 76 } |
| OLD | NEW |