Remove obsolete for_web_contents parameter in FontRenderParamsQuery.
[chromium-blink-merge.git] / chrome / installer / util / uninstall_metrics_unittest.cc
blobaa0ff15c240b2f43cd52bc21d266ba7a6fd02b87
1 // Copyright 2013 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.
5 #include "chrome/installer/util/uninstall_metrics.h"
7 #include <string>
9 #include "base/json/json_string_value_serializer.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace installer {
16 TEST(UninstallMetricsTest, TestExtractUninstallMetrics) {
17 // A make-believe JSON preferences file.
18 std::string pref_string(
19 "{ \n"
20 " \"foo\": \"bar\",\n"
21 " \"uninstall_metrics\": { \n"
22 " \"last_launch_time_sec\": \"1235341118\","
23 " \"last_observed_running_time_sec\": \"1235341183\","
24 " \"launch_count\": \"11\","
25 " \"page_load_count\": \"68\","
26 " \"uptime_sec\": \"809\","
27 " \"installation_date2\": \"1235341141\"\n"
28 " },\n"
29 " \"blah\": {\n"
30 " \"this_sentence_is_true\": false\n"
31 " },\n"
32 " \"user_experience_metrics\": { \n"
33 " \"client_id_timestamp\": \"1234567890\","
34 " \"reporting_enabled\": true\n"
35 " }\n"
36 "} \n");
38 // The URL string we expect to be generated from said make-believe file.
39 base::string16 expected_url_string(
40 L"&installation_date2=1235341141"
41 L"&last_launch_time_sec=1235341118"
42 L"&last_observed_running_time_sec=1235341183"
43 L"&launch_count=11&page_load_count=68"
44 L"&uptime_sec=809");
46 JSONStringValueDeserializer json_deserializer(pref_string);
47 std::string error_message;
49 scoped_ptr<base::Value> root(
50 json_deserializer.Deserialize(NULL, &error_message));
51 ASSERT_TRUE(root.get());
52 base::string16 uninstall_metrics_string;
54 EXPECT_TRUE(
55 ExtractUninstallMetrics(*static_cast<base::DictionaryValue*>(root.get()),
56 &uninstall_metrics_string));
57 EXPECT_EQ(expected_url_string, uninstall_metrics_string);
60 } // namespace installer