OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
6 | 6 |
7 #include "base/test/gtest_util.h" | 7 #include "base/test/gtest_util.h" |
8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
9 #include "components/sync_preferences/testing_pref_service_syncable.h" | 9 #include "components/sync_preferences/testing_pref_service_syncable.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 EXPECT_EQ(IncognitoModePrefs::FORCED, incognito); | 32 EXPECT_EQ(IncognitoModePrefs::FORCED, incognito); |
33 | 33 |
34 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito)); | 34 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito)); |
35 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); | 35 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); |
36 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(-1, &incognito)); | 36 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(-1, &incognito)); |
37 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); | 37 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); |
38 } | 38 } |
39 | 39 |
40 TEST_F(IncognitoModePrefsTest, GetAvailability) { | 40 TEST_F(IncognitoModePrefsTest, GetAvailability) { |
41 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, | 41 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, |
42 new base::FundamentalValue(IncognitoModePrefs::ENABLED)); | 42 new base::Value(IncognitoModePrefs::ENABLED)); |
43 EXPECT_EQ(IncognitoModePrefs::ENABLED, | 43 EXPECT_EQ(IncognitoModePrefs::ENABLED, |
44 IncognitoModePrefs::GetAvailability(&prefs_)); | 44 IncognitoModePrefs::GetAvailability(&prefs_)); |
45 | 45 |
46 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, | 46 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, |
47 new base::FundamentalValue(IncognitoModePrefs::DISABLED)); | 47 new base::Value(IncognitoModePrefs::DISABLED)); |
48 EXPECT_EQ(IncognitoModePrefs::DISABLED, | 48 EXPECT_EQ(IncognitoModePrefs::DISABLED, |
49 IncognitoModePrefs::GetAvailability(&prefs_)); | 49 IncognitoModePrefs::GetAvailability(&prefs_)); |
50 | 50 |
51 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, | 51 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, |
52 new base::FundamentalValue(IncognitoModePrefs::FORCED)); | 52 new base::Value(IncognitoModePrefs::FORCED)); |
53 EXPECT_EQ(IncognitoModePrefs::FORCED, | 53 EXPECT_EQ(IncognitoModePrefs::FORCED, |
54 IncognitoModePrefs::GetAvailability(&prefs_)); | 54 IncognitoModePrefs::GetAvailability(&prefs_)); |
55 } | 55 } |
56 | 56 |
57 typedef IncognitoModePrefsTest IncognitoModePrefsDeathTest; | 57 typedef IncognitoModePrefsTest IncognitoModePrefsDeathTest; |
58 | 58 |
59 TEST_F(IncognitoModePrefsDeathTest, GetAvailabilityBadValue) { | 59 TEST_F(IncognitoModePrefsDeathTest, GetAvailabilityBadValue) { |
60 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, | 60 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, new base::Value(-1)); |
61 new base::FundamentalValue(-1)); | |
62 EXPECT_DCHECK_DEATH({ | 61 EXPECT_DCHECK_DEATH({ |
63 IncognitoModePrefs::Availability availability = | 62 IncognitoModePrefs::Availability availability = |
64 IncognitoModePrefs::GetAvailability(&prefs_); | 63 IncognitoModePrefs::GetAvailability(&prefs_); |
65 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); | 64 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); |
66 }); | 65 }); |
67 } | 66 } |
OLD | NEW |