Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <Foundation/Foundation.h> | |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/sys_string_conversions.h" | |
| 10 #include "chrome/installer/util/google_update_constants.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | |
| 12 #include "testing/platform_test.h" | |
| 13 | |
| 14 namespace google_update { | |
| 15 | |
| 16 bool GetCollectStatsConsentFromDictionary(NSDictionary *dict); | |
| 17 | |
| 18 } // namespace google_update | |
| 19 | |
| 20 | |
| 21 class GoogleUpdateTest : public PlatformTest { | |
| 22 }; | |
| 23 | |
| 24 TEST_F(GoogleUpdateTest, StatsConstent) { | |
|
John Grabowski
2009/05/18 21:49:50
Excellent
| |
| 25 using google_update::GetCollectStatsConsentFromDictionary; | |
| 26 | |
| 27 // Stats are on by default. | |
| 28 NSDictionary *empty_dict = [NSDictionary dictionary]; | |
|
John Grabowski
2009/05/18 21:49:50
Blah * --> Blah*
in lots of places here
| |
| 29 ASSERT_TRUE(GetCollectStatsConsentFromDictionary(empty_dict)); | |
| 30 | |
| 31 NSString *collect_stats_key = base::SysWideToNSString( | |
| 32 google_update::kRegUsageStatsField); | |
| 33 | |
| 34 // Stats reporting is ON. | |
| 35 NSNumber *stats_enabled = [NSNumber numberWithBool:YES]; | |
| 36 NSDictionary *enabled_dict = [NSDictionary | |
| 37 dictionaryWithObject:stats_enabled | |
| 38 forKey:collect_stats_key]; | |
| 39 ASSERT_TRUE(GetCollectStatsConsentFromDictionary(enabled_dict)); | |
| 40 | |
| 41 // Stats reporting is OFF. | |
| 42 NSNumber *stats_disabled = [NSNumber numberWithBool:NO]; | |
| 43 NSDictionary *disabled_dict = [NSDictionary | |
| 44 dictionaryWithObject:stats_disabled | |
| 45 forKey:collect_stats_key]; | |
| 46 ASSERT_FALSE(GetCollectStatsConsentFromDictionary(disabled_dict)); | |
| 47 | |
|
John Grabowski
2009/05/18 21:49:50
Stat not set test (which will be the most common c
| |
| 48 // Check that we fail gracefully if an object of the wrong type is present. | |
| 49 NSDictionary *wrong_type_dict = [NSDictionary | |
| 50 dictionaryWithObject:empty_dict | |
| 51 forKey:collect_stats_key]; | |
| 52 ASSERT_TRUE(GetCollectStatsConsentFromDictionary(wrong_type_dict)); | |
| 53 } | |
| OLD | NEW |