blob: 2ac7e5d3ba54afc14c4bc0e1d23369037e29b489 (
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
56
57
58
59
|
// Copyright (c) 2012 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 "base/memory/scoped_ptr.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/protector/base_setting_change.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace protector {
namespace {
const char kStartupUrl[] = "http://example.com/";
} // namespace
class PrefsBackupInvalidChangeTest : public testing::Test {
protected:
TestingProfile profile_;
};
// Test that correct default values are applied by Init.
TEST_F(PrefsBackupInvalidChangeTest, Defaults) {
SessionStartupPref startup_pref(SessionStartupPref::URLS);
startup_pref.urls.push_back(GURL(kStartupUrl));
SessionStartupPref::SetStartupPref(&profile_, startup_pref);
scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
change->Init(&profile_);
SessionStartupPref new_startup_pref =
SessionStartupPref::GetStartupPref(&profile_);
// Startup type should be reset to default.
EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), new_startup_pref.type);
// Startup URLs should be left unchanged.
EXPECT_EQ(1UL, new_startup_pref.urls.size());
EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
}
// Test that "restore last session" setting is not changed by Init.
TEST_F(PrefsBackupInvalidChangeTest, DefaultsWithSessionRestore) {
SessionStartupPref startup_pref(SessionStartupPref::LAST);
startup_pref.urls.push_back(GURL(kStartupUrl));
SessionStartupPref::SetStartupPref(&profile_, startup_pref);
scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
change->Init(&profile_);
SessionStartupPref new_startup_pref =
SessionStartupPref::GetStartupPref(&profile_);
// Both startup type and startup URLs should be left unchanged.
EXPECT_EQ(SessionStartupPref::LAST, new_startup_pref.type);
EXPECT_EQ(1UL, new_startup_pref.urls.size());
EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
}
} // namespace protector
|