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> | |
|
Mark Mentovai
2009/08/18 21:51:48
#import this one.
| |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/sys_string_conversions.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 #include "testing/platform_test.h" | |
| 12 | |
| 13 // This is a test for temporary code, see chrome/browser/first_run_mac.mm | |
| 14 // for details. | |
|
Mark Mentovai
2009/08/18 21:51:48
I'm surprised you're adding a test for temporary c
| |
| 15 | |
| 16 namespace old_first_run_mac { | |
| 17 | |
| 18 bool IsOldChromeFirstRunFromDictionary(NSDictionary *dict, | |
| 19 bool *usage_stats_enabled); | |
| 20 | |
| 21 extern const NSString *kOldUsageStatsPrefName; | |
| 22 } // namespace google_update | |
| 23 | |
| 24 | |
| 25 class FirstRunMigrationTest : public PlatformTest { | |
| 26 }; | |
| 27 | |
| 28 TEST_F(FirstRunMigrationTest, MigrateOldFirstRunSettings) { | |
| 29 using old_first_run_mac::IsOldChromeFirstRunFromDictionary; | |
| 30 using old_first_run_mac::kOldUsageStatsPrefName; | |
| 31 | |
| 32 // Stats are off by default. | |
| 33 bool stats_on; | |
| 34 NSDictionary* empty_dict = [NSDictionary dictionary]; | |
| 35 EXPECT_FALSE(IsOldChromeFirstRunFromDictionary(empty_dict, &stats_on)); | |
| 36 EXPECT_FALSE(stats_on); | |
| 37 | |
| 38 // Stats reporting is ON. | |
| 39 NSNumber* stats_enabled = [NSNumber numberWithBool:YES]; | |
| 40 NSDictionary* enabled_dict = [NSDictionary | |
| 41 dictionaryWithObject:stats_enabled | |
| 42 forKey:kOldUsageStatsPrefName]; | |
| 43 EXPECT_TRUE(IsOldChromeFirstRunFromDictionary(enabled_dict, &stats_on)); | |
| 44 EXPECT_TRUE(stats_on); | |
| 45 | |
| 46 // Stats reporting is OFF. | |
| 47 stats_enabled = [NSNumber numberWithBool:NO]; | |
| 48 enabled_dict = [NSDictionary | |
| 49 dictionaryWithObject:stats_enabled | |
| 50 forKey:kOldUsageStatsPrefName]; | |
| 51 EXPECT_TRUE(IsOldChromeFirstRunFromDictionary(enabled_dict, &stats_on)); | |
| 52 EXPECT_FALSE(stats_on); | |
| 53 | |
| 54 | |
| 55 // If an object of the wrong type is present, we still consider this to | |
| 56 // be a first run, but stats reporting is disabled. | |
| 57 NSDictionary* wrong_type_dict = [NSDictionary | |
| 58 dictionaryWithObject:empty_dict | |
| 59 forKey:kOldUsageStatsPrefName]; | |
| 60 EXPECT_TRUE(IsOldChromeFirstRunFromDictionary(wrong_type_dict, &stats_on)); | |
| 61 EXPECT_FALSE(stats_on); | |
| 62 } | |
| OLD | NEW |