Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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/browser/prefs/incognito_mode_prefs.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 #include "chrome/test/testing_pref_service.h" | |
| 9 #include "chrome/common/pref_names.h" | |
|
Mattias Nissler (ping if slow)
2011/07/29 10:33:23
alphabetize
rustema
2011/07/30 06:17:37
Done.
| |
| 10 | |
| 11 class IncognitoModePrefsTest : public testing::Test { | |
| 12 protected: | |
| 13 virtual void SetUp() { | |
| 14 prefs_.reset(new TestingPrefService()); | |
| 15 IncognitoModePrefs::RegisterUserPrefs(prefs_.get()); | |
| 16 } | |
| 17 | |
| 18 scoped_ptr<TestingPrefService> prefs_; | |
| 19 }; | |
| 20 | |
| 21 TEST_F(IncognitoModePrefsTest, IntToAvailability) { | |
| 22 ASSERT_EQ(0, IncognitoModePrefs::ENABLED); | |
| 23 ASSERT_EQ(1, IncognitoModePrefs::DISABLED); | |
| 24 ASSERT_EQ(2, IncognitoModePrefs::FORCED); | |
| 25 | |
| 26 IncognitoModePrefs::Availability incognito; | |
| 27 EXPECT_TRUE(IncognitoModePrefs::IntToAvailability(0, &incognito)); | |
| 28 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); | |
| 29 EXPECT_TRUE(IncognitoModePrefs::IntToAvailability(1, &incognito)); | |
| 30 EXPECT_EQ(IncognitoModePrefs::DISABLED, incognito); | |
| 31 EXPECT_TRUE(IncognitoModePrefs::IntToAvailability(2, &incognito)); | |
| 32 EXPECT_EQ(IncognitoModePrefs::FORCED, incognito); | |
| 33 | |
| 34 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito)); | |
| 35 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); | |
| 36 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(-1, &incognito)); | |
| 37 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); | |
| 38 } | |
| 39 | |
| 40 TEST_F(IncognitoModePrefsTest, GetAvailability) { | |
| 41 prefs_->SetUserPref(prefs::kIncognitoModeAvailability, | |
| 42 Value::CreateIntegerValue(IncognitoModePrefs::ENABLED)); | |
| 43 EXPECT_EQ(IncognitoModePrefs::ENABLED, | |
| 44 IncognitoModePrefs::GetAvailability(prefs_.get())); | |
| 45 | |
| 46 prefs_->SetUserPref(prefs::kIncognitoModeAvailability, | |
| 47 Value::CreateIntegerValue(IncognitoModePrefs::DISABLED)); | |
| 48 EXPECT_EQ(IncognitoModePrefs::DISABLED, | |
| 49 IncognitoModePrefs::GetAvailability(prefs_.get())); | |
| 50 | |
| 51 prefs_->SetUserPref(prefs::kIncognitoModeAvailability, | |
| 52 Value::CreateIntegerValue(IncognitoModePrefs::FORCED)); | |
| 53 EXPECT_EQ(IncognitoModePrefs::FORCED, | |
| 54 IncognitoModePrefs::GetAvailability(prefs_.get())); | |
| 55 } | |
| 56 | |
| 57 typedef IncognitoModePrefsTest IncognitoModePrefsDeathTest; | |
| 58 | |
| 59 TEST_F(IncognitoModePrefsDeathTest, GetAvailabilityBadValue) { | |
| 60 prefs_->SetUserPref(prefs::kIncognitoModeAvailability, | |
| 61 Value::CreateIntegerValue(-1)); | |
| 62 EXPECT_DEBUG_DEATH({ | |
|
Mattias Nissler (ping if slow)
2011/07/29 11:29:08
Pawel, what's the current policy on death tests? I
| |
| 63 IncognitoModePrefs::Availability availability = | |
| 64 IncognitoModePrefs::GetAvailability(prefs_.get()); | |
| 65 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); | |
| 66 }, ""); | |
| 67 } | |
| OLD | NEW |