1 // Copyright (c) 2011 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 "chrome/installer/util/google_update_settings.h" 6 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/platform_test.h" 8 9 class GoogleUpdateTest : public PlatformTest { 10 }; 11 TEST_F(GoogleUpdateTest,StatsConsent)12TEST_F(GoogleUpdateTest, StatsConsent) { 13 // Stats are off by default. 14 EXPECT_FALSE(GoogleUpdateSettings::GetCollectStatsConsent()); 15 // Stats reporting is ON. 16 EXPECT_TRUE(GoogleUpdateSettings::SetCollectStatsConsent(true)); 17 EXPECT_TRUE(GoogleUpdateSettings::GetCollectStatsConsent()); 18 // Stats reporting is OFF. 19 EXPECT_TRUE(GoogleUpdateSettings::SetCollectStatsConsent(false)); 20 EXPECT_FALSE(GoogleUpdateSettings::GetCollectStatsConsent()); 21 } 22 23 #if defined(OS_WIN) 24 TEST_F(GoogleUpdateTest,LastRunTime)25TEST_F(GoogleUpdateTest, LastRunTime) { 26 // Querying the value that does not exists should fail. 27 EXPECT_TRUE(GoogleUpdateSettings::RemoveLastRunTime()); 28 EXPECT_EQ(-1, GoogleUpdateSettings::GetLastRunTime()); 29 // Setting and querying the last update time in fast sequence 30 // should give 0 days. 31 EXPECT_TRUE(GoogleUpdateSettings::SetLastRunTime()); 32 EXPECT_EQ(0, GoogleUpdateSettings::GetLastRunTime()); 33 } 34 TEST_F(GoogleUpdateTest,ShouldShowSearchEngineDialog)35TEST_F(GoogleUpdateTest, ShouldShowSearchEngineDialog) { 36 // Test some brand codes to ensure that future changes to this method won't 37 // go unnoticed. 38 const wchar_t* false_brand1 = L"CHFO"; 39 EXPECT_FALSE(GoogleUpdateSettings::IsOrganicFirstRun( 40 false_brand1)); 41 const wchar_t* false_brand2 = L"CHMA"; 42 EXPECT_FALSE(GoogleUpdateSettings::IsOrganicFirstRun( 43 false_brand2)); 44 const wchar_t* good_brand1 = L"EUBA"; 45 EXPECT_TRUE(GoogleUpdateSettings::IsOrganicFirstRun( 46 good_brand1)); 47 const wchar_t* good_brand2 = L"GGRA"; 48 EXPECT_TRUE(GoogleUpdateSettings::IsOrganicFirstRun( 49 good_brand2)); 50 } 51 52 #endif // defined(OS_WIN) 53