| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Unit tests for GoogleChromeDistribution class. | 5 // Unit tests for GoogleChromeDistribution class. |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/common/json_value_serializer.h" | 10 #include "chrome/common/json_value_serializer.h" |
| 11 #include "chrome/installer/util/browser_distribution.h" | 11 #include "chrome/installer/util/browser_distribution.h" |
| 12 #include "chrome/installer/util/google_update_constants.h" | 12 #include "chrome/installer/util/google_update_constants.h" |
| 13 #include "chrome/installer/util/google_chrome_distribution.h" | 13 #include "chrome/installer/util/google_chrome_distribution.h" |
| 14 #include "chrome/installer/util/master_preferences.h" | |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 #if defined(GOOGLE_CHROME_BUILD) | 16 #if defined(GOOGLE_CHROME_BUILD) |
| 18 TEST(GoogleChromeDistTest, TestExtractUninstallMetrics) { | 17 TEST(GoogleChromeDistTest, TestExtractUninstallMetrics) { |
| 19 // A make-believe JSON preferences file. | 18 // A make-believe JSON preferences file. |
| 20 std::string pref_string( | 19 std::string pref_string( |
| 21 "{ \n" | 20 "{ \n" |
| 22 " \"foo\": \"bar\",\n" | 21 " \"foo\": \"bar\",\n" |
| 23 " \"uninstall_metrics\": { \n" | 22 " \"uninstall_metrics\": { \n" |
| 24 " \"last_launch_time_sec\": \"1235341118\"," | 23 " \"last_launch_time_sec\": \"1235341118\"," |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 L"&launch_count=11&page_load_count=68" | 44 L"&launch_count=11&page_load_count=68" |
| 46 L"&uptime_sec=809"); | 45 L"&uptime_sec=809"); |
| 47 | 46 |
| 48 JSONStringValueSerializer json_deserializer(pref_string); | 47 JSONStringValueSerializer json_deserializer(pref_string); |
| 49 std::string error_message; | 48 std::string error_message; |
| 50 | 49 |
| 51 scoped_ptr<Value> root(json_deserializer.Deserialize(NULL, &error_message)); | 50 scoped_ptr<Value> root(json_deserializer.Deserialize(NULL, &error_message)); |
| 52 ASSERT_TRUE(root.get()); | 51 ASSERT_TRUE(root.get()); |
| 53 std::wstring uninstall_metrics_string; | 52 std::wstring uninstall_metrics_string; |
| 54 | 53 |
| 55 const installer::MasterPreferences& prefs = | |
| 56 installer::MasterPreferences::ForCurrentProcess(); | |
| 57 | |
| 58 GoogleChromeDistribution* dist = static_cast<GoogleChromeDistribution*>( | 54 GoogleChromeDistribution* dist = static_cast<GoogleChromeDistribution*>( |
| 59 BrowserDistribution::GetSpecificDistribution( | 55 BrowserDistribution::GetSpecificDistribution( |
| 60 BrowserDistribution::CHROME_BROWSER, prefs)); | 56 BrowserDistribution::CHROME_BROWSER)); |
| 61 | 57 |
| 62 EXPECT_TRUE( | 58 EXPECT_TRUE( |
| 63 dist->ExtractUninstallMetrics(*static_cast<DictionaryValue*>(root.get()), | 59 dist->ExtractUninstallMetrics(*static_cast<DictionaryValue*>(root.get()), |
| 64 &uninstall_metrics_string)); | 60 &uninstall_metrics_string)); |
| 65 EXPECT_EQ(expected_url_string, uninstall_metrics_string); | 61 EXPECT_EQ(expected_url_string, uninstall_metrics_string); |
| 66 } | 62 } |
| 67 #endif // defined(GOOGLE_CHROME_BUILD) | 63 #endif // defined(GOOGLE_CHROME_BUILD) |
| OLD | NEW |