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 "chrome/common/pref_names.h" | |
8 #include "chrome/test/base/testing_pref_service.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
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_; | |
Mattias Nissler (ping if slow)
2011/08/03 09:16:08
You can just use a regular member, no need to wrap
rustema
2011/08/04 07:00:49
Done.
| |
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({ | |
63 IncognitoModePrefs::Availability availability = | |
64 IncognitoModePrefs::GetAvailability(prefs_.get()); | |
65 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); | |
66 }, ""); | |
67 } | |
OLD | NEW |