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

Side by Side Diff: chrome/browser/prefs/incognito_mode_prefs_unittest.cc

Issue 385263004: Get rid of some uses of CreateIntegerValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/common/pref_names.h" 7 #include "chrome/common/pref_names.h"
8 #include "chrome/test/base/testing_pref_service_syncable.h" 8 #include "chrome/test/base/testing_pref_service_syncable.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 20 matching lines...) Expand all
31 EXPECT_EQ(IncognitoModePrefs::FORCED, incognito); 31 EXPECT_EQ(IncognitoModePrefs::FORCED, incognito);
32 32
33 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito)); 33 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito));
34 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); 34 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito);
35 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(-1, &incognito)); 35 EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(-1, &incognito));
36 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); 36 EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito);
37 } 37 }
38 38
39 TEST_F(IncognitoModePrefsTest, GetAvailability) { 39 TEST_F(IncognitoModePrefsTest, GetAvailability) {
40 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, 40 prefs_.SetUserPref(prefs::kIncognitoModeAvailability,
41 base::Value::CreateIntegerValue( 41 new base::FundamentalValue(IncognitoModePrefs::ENABLED));
42 IncognitoModePrefs::ENABLED));
43 EXPECT_EQ(IncognitoModePrefs::ENABLED, 42 EXPECT_EQ(IncognitoModePrefs::ENABLED,
44 IncognitoModePrefs::GetAvailability(&prefs_)); 43 IncognitoModePrefs::GetAvailability(&prefs_));
45 44
46 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, 45 prefs_.SetUserPref(prefs::kIncognitoModeAvailability,
47 base::Value::CreateIntegerValue( 46 new base::FundamentalValue(IncognitoModePrefs::DISABLED));
48 IncognitoModePrefs::DISABLED));
49 EXPECT_EQ(IncognitoModePrefs::DISABLED, 47 EXPECT_EQ(IncognitoModePrefs::DISABLED,
50 IncognitoModePrefs::GetAvailability(&prefs_)); 48 IncognitoModePrefs::GetAvailability(&prefs_));
51 49
52 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, 50 prefs_.SetUserPref(prefs::kIncognitoModeAvailability,
53 base::Value::CreateIntegerValue( 51 new base::FundamentalValue(IncognitoModePrefs::FORCED));
54 IncognitoModePrefs::FORCED));
55 EXPECT_EQ(IncognitoModePrefs::FORCED, 52 EXPECT_EQ(IncognitoModePrefs::FORCED,
56 IncognitoModePrefs::GetAvailability(&prefs_)); 53 IncognitoModePrefs::GetAvailability(&prefs_));
57 } 54 }
58 55
59 typedef IncognitoModePrefsTest IncognitoModePrefsDeathTest; 56 typedef IncognitoModePrefsTest IncognitoModePrefsDeathTest;
60 57
61 #if GTEST_HAS_DEATH_TEST 58 #if GTEST_HAS_DEATH_TEST
62 TEST_F(IncognitoModePrefsDeathTest, GetAvailabilityBadValue) { 59 TEST_F(IncognitoModePrefsDeathTest, GetAvailabilityBadValue) {
63 prefs_.SetUserPref(prefs::kIncognitoModeAvailability, 60 prefs_.SetUserPref(prefs::kIncognitoModeAvailability,
64 base::Value::CreateIntegerValue(-1)); 61 new base::FundamentalValue(-1));
65 #if defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) 62 #if defined(NDEBUG) && defined(DCHECK_ALWAYS_ON)
66 EXPECT_DEATH({ 63 EXPECT_DEATH({
67 IncognitoModePrefs::Availability availability = 64 IncognitoModePrefs::Availability availability =
68 IncognitoModePrefs::GetAvailability(&prefs_); 65 IncognitoModePrefs::GetAvailability(&prefs_);
69 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); 66 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability);
70 }, ""); 67 }, "");
71 #else 68 #else
72 EXPECT_DEBUG_DEATH({ 69 EXPECT_DEBUG_DEATH({
73 IncognitoModePrefs::Availability availability = 70 IncognitoModePrefs::Availability availability =
74 IncognitoModePrefs::GetAvailability(&prefs_); 71 IncognitoModePrefs::GetAvailability(&prefs_);
75 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); 72 EXPECT_EQ(IncognitoModePrefs::ENABLED, availability);
76 }, ""); 73 }, "");
77 #endif 74 #endif
78 } 75 }
79 #endif // GTEST_HAS_DEATH_TEST 76 #endif // GTEST_HAS_DEATH_TEST
OLDNEW
« no previous file with comments | « chrome/browser/prefs/command_line_pref_store.cc ('k') | chrome/browser/prefs/pref_hash_calculator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698