Chromium Code Reviews| Index: chrome/browser/google_update_settings_mac_unittest.mm |
| diff --git a/chrome/browser/google_update_settings_mac_unittest.mm b/chrome/browser/google_update_settings_mac_unittest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e26f22642e6d2ec9af331b3cd972cc57428ab132 |
| --- /dev/null |
| +++ b/chrome/browser/google_update_settings_mac_unittest.mm |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2009 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. |
| + |
| +#include <Foundation/Foundation.h> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/logging.h" |
| +#include "base/sys_string_conversions.h" |
| +#include "chrome/installer/util/google_update_constants.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "testing/platform_test.h" |
| + |
| +namespace google_update { |
| + |
| +bool GetCollectStatsConsentFromDictionary(NSDictionary *dict); |
| + |
| +} // namespace google_update |
| + |
| + |
| +class GoogleUpdateTest : public PlatformTest { |
| +}; |
| + |
| +TEST_F(GoogleUpdateTest, StatsConstent) { |
|
John Grabowski
2009/05/18 21:49:50
Excellent
|
| + using google_update::GetCollectStatsConsentFromDictionary; |
| + |
| + // Stats are on by default. |
| + NSDictionary *empty_dict = [NSDictionary dictionary]; |
|
John Grabowski
2009/05/18 21:49:50
Blah * --> Blah*
in lots of places here
|
| + ASSERT_TRUE(GetCollectStatsConsentFromDictionary(empty_dict)); |
| + |
| + NSString *collect_stats_key = base::SysWideToNSString( |
| + google_update::kRegUsageStatsField); |
| + |
| + // Stats reporting is ON. |
| + NSNumber *stats_enabled = [NSNumber numberWithBool:YES]; |
| + NSDictionary *enabled_dict = [NSDictionary |
| + dictionaryWithObject:stats_enabled |
| + forKey:collect_stats_key]; |
| + ASSERT_TRUE(GetCollectStatsConsentFromDictionary(enabled_dict)); |
| + |
| + // Stats reporting is OFF. |
| + NSNumber *stats_disabled = [NSNumber numberWithBool:NO]; |
| + NSDictionary *disabled_dict = [NSDictionary |
| + dictionaryWithObject:stats_disabled |
| + forKey:collect_stats_key]; |
| + ASSERT_FALSE(GetCollectStatsConsentFromDictionary(disabled_dict)); |
| + |
|
John Grabowski
2009/05/18 21:49:50
Stat not set test (which will be the most common c
|
| + // Check that we fail gracefully if an object of the wrong type is present. |
| + NSDictionary *wrong_type_dict = [NSDictionary |
| + dictionaryWithObject:empty_dict |
| + forKey:collect_stats_key]; |
| + ASSERT_TRUE(GetCollectStatsConsentFromDictionary(wrong_type_dict)); |
| +} |