Index: components/metrics/mock_metrics_service_client.h |
diff --git a/components/metrics/mock_metrics_service_client.h b/components/metrics/mock_metrics_service_client.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fa415a9d03a0aa6a6d39c76c692beaaec52e8734 |
--- /dev/null |
+++ b/components/metrics/mock_metrics_service_client.h |
@@ -0,0 +1,68 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_METRICS_MOCK_METRICS_SERVICE_CLIENT_H_ |
+#define COMPONENTS_METRICS_MOCK_METRICS_SERVICE_CLIENT_H_ |
+ |
+#include <string> |
+ |
+#include "base/callback.h" |
+ |
+#include "components/metrics/metrics_log_uploader.h" |
+#include "components/metrics/metrics_service_client.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+ |
+namespace metrics { |
+ |
+class MockMetricsServiceClient : public MetricsServiceClient { |
+ public: |
+ MockMetricsServiceClient(); |
+ virtual ~MockMetricsServiceClient(); |
+ |
+ // GMock doesn't support the return type of scoped_ptr<> because |
+ // scoped_ptr is uncopyable. This is a workaround which defines |
+ // |MockCreateUploader| as a mock method and makes |CreateUploader| |
+ // call the mocked method. |
+ // Use |MockCreateUploader| for setting/testing expectations. |
+ MOCK_METHOD3(MockCreateUploader, |
+ MetricsLogUploader*( |
+ const std::string& server_url, |
+ const std::string& mime_type, |
+ const base::Callback<void(int)>& on_upload_complete)); |
+ virtual scoped_ptr<MetricsLogUploader> CreateUploader( |
+ const std::string& server_url, |
+ const std::string& mime_type, |
+ const base::Callback<void(int)>& on_upload_complete); |
+ MOCK_METHOD1(SetMetricsClientId, |
+ void(const std::string& client_id)); |
+ MOCK_METHOD0(IsOffTheRecordSessionActive, |
+ bool()); |
+ MOCK_METHOD0(GetProduct, |
+ int32_t()); |
+ MOCK_METHOD0(GetApplicationLocale, |
+ std::string()); |
+ MOCK_METHOD1(GetBrand, |
+ bool(std::string* brand_code)); |
+ MOCK_METHOD0(GetChannel, |
+ SystemProfileProto::Channel()); |
+ MOCK_METHOD0(GetVersionString, |
+ std::string()); |
+ MOCK_METHOD0(OnLogUploadComplete, |
+ void()); |
+ MOCK_METHOD1(StartGatheringMetrics, |
+ void(const base::Closure& done_callback)); |
+ MOCK_METHOD1(CollectFinalMetrics, |
+ void(const base::Closure& done_callback)); |
+ MOCK_METHOD0(GetRegistryBackupKey, |
+ base::string16()); |
+ |
+ void DoNothing(int x); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MockMetricsServiceClient); |
+}; |
+ |
+} // namespace metrics |
+ |
+#endif // COMPONENTS_METRICS_MOCK_METRICS_SERVICE_CLIENT_H_ |