Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1985)

Unified Diff: chrome/browser/first_run_migration_mac_unittest.mm

Issue 173020: Make Mac first run store sentinel in Profile directory. (Closed)
Patch Set: spelling Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/first_run_migration_mac_unittest.mm
diff --git a/chrome/browser/first_run_migration_mac_unittest.mm b/chrome/browser/first_run_migration_mac_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..ca3560e40261eca261339fb7f5f03f20e634f75f
--- /dev/null
+++ b/chrome/browser/first_run_migration_mac_unittest.mm
@@ -0,0 +1,62 @@
+// 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>
Mark Mentovai 2009/08/18 21:51:48 #import this one.
+
+#include "base/basictypes.h"
+#include "base/logging.h"
+#include "base/sys_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+
+// This is a test for temporary code, see chrome/browser/first_run_mac.mm
+// for details.
Mark Mentovai 2009/08/18 21:51:48 I'm surprised you're adding a test for temporary c
+
+namespace old_first_run_mac {
+
+bool IsOldChromeFirstRunFromDictionary(NSDictionary *dict,
+ bool *usage_stats_enabled);
+
+extern const NSString *kOldUsageStatsPrefName;
+} // namespace google_update
+
+
+class FirstRunMigrationTest : public PlatformTest {
+};
+
+TEST_F(FirstRunMigrationTest, MigrateOldFirstRunSettings) {
+ using old_first_run_mac::IsOldChromeFirstRunFromDictionary;
+ using old_first_run_mac::kOldUsageStatsPrefName;
+
+ // Stats are off by default.
+ bool stats_on;
+ NSDictionary* empty_dict = [NSDictionary dictionary];
+ EXPECT_FALSE(IsOldChromeFirstRunFromDictionary(empty_dict, &stats_on));
+ EXPECT_FALSE(stats_on);
+
+ // Stats reporting is ON.
+ NSNumber* stats_enabled = [NSNumber numberWithBool:YES];
+ NSDictionary* enabled_dict = [NSDictionary
+ dictionaryWithObject:stats_enabled
+ forKey:kOldUsageStatsPrefName];
+ EXPECT_TRUE(IsOldChromeFirstRunFromDictionary(enabled_dict, &stats_on));
+ EXPECT_TRUE(stats_on);
+
+ // Stats reporting is OFF.
+ stats_enabled = [NSNumber numberWithBool:NO];
+ enabled_dict = [NSDictionary
+ dictionaryWithObject:stats_enabled
+ forKey:kOldUsageStatsPrefName];
+ EXPECT_TRUE(IsOldChromeFirstRunFromDictionary(enabled_dict, &stats_on));
+ EXPECT_FALSE(stats_on);
+
+
+ // If an object of the wrong type is present, we still consider this to
+ // be a first run, but stats reporting is disabled.
+ NSDictionary* wrong_type_dict = [NSDictionary
+ dictionaryWithObject:empty_dict
+ forKey:kOldUsageStatsPrefName];
+ EXPECT_TRUE(IsOldChromeFirstRunFromDictionary(wrong_type_dict, &stats_on));
+ EXPECT_FALSE(stats_on);
+}

Powered by Google App Engine
This is Rietveld 408576698