Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: blimp/engine/app/blimp_metrics_service_client_unittest.cc

Issue 1885673003: Create and integrate a metrics service client into Blimp engine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move newline and ASSERT as requested. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/engine/app/blimp_metrics_service_client.h"
6
7 #include <list>
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
13 #include "base/test/test_simple_task_runner.h"
14 #include "base/thread_task_runner_handle.h"
15 #include "components/metrics/metrics_service.h"
16 #include "components/pref_registry/pref_registry_syncable.h"
17 #include "components/prefs/in_memory_pref_store.h"
18 #include "components/prefs/pref_service.h"
19 #include "components/prefs/pref_service_factory.h"
20 #include "net/url_request/url_request_context_getter.h"
21 #include "net/url_request/url_request_test_util.h"
22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h"
24
25 namespace blimp {
26 namespace engine {
27 // Shows notifications which correspond to PersistentPrefStore's reading errors.
28 void HandleReadError(PersistentPrefStore::PrefReadError error) {
29 }
30
31 class BlimpMetricsServiceClientTest : public testing::Test {
32 protected:
33 void SetUp() override;
34 void TearDown() override;
35
36 void SetUpPrefRegistry();
37 void SetUpPrefService();
38 void SetUpRequestContextGetter();
39
40 base::MessageLoop message_loop_;
41 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_;
42 std::unique_ptr<PrefService> pref_service_;
43 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
44 };
45
46 void BlimpMetricsServiceClientTest::SetUp() {
47 // Set up all deps and then InitializeBlimpMetrics.
48 SetUpPrefRegistry();
49 SetUpPrefService();
50 SetUpRequestContextGetter();
51 base::SetRecordActionTaskRunner(message_loop_.task_runner());
52 InitializeBlimpMetrics(std::move(pref_service_), request_context_getter_);
53 base::RunLoop().RunUntilIdle();
54
55 // Checks of InitializeBlimpMetrics.
56 // TODO(jessicag): Check request_context_getter_ set.
57 // PrefService unique pointer moved to BlimpMetricsServiceClient.
58 EXPECT_EQ(nullptr, pref_service_.get());
59
60 // TODO(jessicag): Confirm registration of metrics providers.
61 // TODO(jessicag): MetricsService initializes recording state.
62 // TODO(jessicag): Confirm MetricsService::Start() is called.
63 }
64
65 void BlimpMetricsServiceClientTest::TearDown() {
66 FinalizeBlimpMetrics();
67 base::RunLoop().RunUntilIdle();
68 // TODO(jessicag): Ensure MetricsService::Stop() is called.
69 }
70
71 void BlimpMetricsServiceClientTest::SetUpPrefRegistry() {
72 pref_registry_ = new user_prefs::PrefRegistrySyncable();
73 metrics::MetricsService::RegisterPrefs(pref_registry_.get());
74 }
75
76 void BlimpMetricsServiceClientTest::SetUpPrefService() {
77 PrefServiceFactory pref_service_factory;
78 pref_service_factory.set_user_prefs(new InMemoryPrefStore());
79 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError));
80 pref_service_ = pref_service_factory.Create(pref_registry_.get());
81 ASSERT_NE(nullptr, pref_service_.get());
82 }
83
84 void BlimpMetricsServiceClientTest::SetUpRequestContextGetter() {
85 request_context_getter_ =
86 new net::TestURLRequestContextGetter(base::ThreadTaskRunnerHandle::Get());
87 }
88
89 TEST_F(BlimpMetricsServiceClientTest, InitializeFinalize) {
90 // SetUp and TearDown handle initialization and finalization checks.
91 }
92
93 } // namespace engine
94 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/app/blimp_metrics_service_client.cc ('k') | blimp/engine/common/blimp_browser_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698