blob: 42fa47a98ff9a051bdfc362e5a3cb0912e9576fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/dom_ui/shown_sections_handler.h"
#include "base/file_path.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/pref_value_store.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
class ShownSectionsHandlerTest : public testing::Test {
};
TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) {
// Create a preference value that has only user defined
// preference values.
FilePath user_prefs = FilePath();
scoped_ptr<PrefService> pref(PrefService::CreateUserPrefService(user_prefs));
// Set an *old* value
pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
pref->SetInteger(prefs::kNTPShownSections, THUMB);
ShownSectionsHandler::MigrateUserPrefs(pref.get(), 0, 1);
int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
EXPECT_TRUE(shown_sections & THUMB);
EXPECT_FALSE(shown_sections & LIST);
EXPECT_FALSE(shown_sections & RECENT);
EXPECT_TRUE(shown_sections & TIPS);
EXPECT_TRUE(shown_sections & SYNC);
}
TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs1To2) {
FilePath user_prefs = FilePath();
scoped_ptr<PrefService> pref(PrefService::CreateUserPrefService(user_prefs));
// Set an *old* value
pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
pref->SetInteger(prefs::kNTPShownSections, LIST);
ShownSectionsHandler::MigrateUserPrefs(pref.get(), 1, 2);
int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
EXPECT_TRUE(shown_sections & THUMB);
EXPECT_FALSE(shown_sections & LIST);
}
|