| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
| 10 #include "chrome/browser/dom_ui/new_tab_ui.h" | 10 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 int thumbnails_count = -1; | 68 int thumbnails_count = -1; |
| 69 ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", | 69 ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", |
| 70 L"window.domAutomationController.send(" | 70 L"window.domAutomationController.send(" |
| 71 L"document.getElementsByClassName('thumbnail-container').length)", | 71 L"document.getElementsByClassName('thumbnail-container').length)", |
| 72 &thumbnails_count)); | 72 &thumbnails_count)); |
| 73 EXPECT_GT(thumbnails_count, 0); | 73 EXPECT_GT(thumbnails_count, 0); |
| 74 } | 74 } |
| 75 | 75 |
| 76 TEST_F(NewTabUITest, UpdateUserPrefsVersion) { | 76 TEST_F(NewTabUITest, UpdateUserPrefsVersion) { |
| 77 // PrefService with JSON user-pref file only, no enforced or advised prefs. | 77 // PrefService with JSON user-pref file only, no enforced or advised prefs. |
| 78 PrefService prefs(new PrefValueStore( | 78 FilePath user_prefs = FilePath(); |
| 79 NULL, /* no enforced prefs */ | 79 scoped_ptr<PrefService> prefs( |
| 80 new JsonPrefStore( | 80 PrefService::CreateUserPrefService(user_prefs)); |
| 81 FilePath(), | |
| 82 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), | |
| 83 /* user prefs */ | |
| 84 NULL /* no advised prefs */)); | |
| 85 | 81 |
| 86 // Does the migration | 82 // Does the migration |
| 87 NewTabUI::RegisterUserPrefs(&prefs); | 83 NewTabUI::RegisterUserPrefs(prefs.get()); |
| 88 | 84 |
| 89 ASSERT_EQ(NewTabUI::current_pref_version(), | 85 ASSERT_EQ(NewTabUI::current_pref_version(), |
| 90 prefs.GetInteger(prefs::kNTPPrefVersion)); | 86 prefs->GetInteger(prefs::kNTPPrefVersion)); |
| 91 | 87 |
| 92 // Reset the version | 88 // Reset the version |
| 93 prefs.ClearPref(prefs::kNTPPrefVersion); | 89 prefs->ClearPref(prefs::kNTPPrefVersion); |
| 94 ASSERT_EQ(0, prefs.GetInteger(prefs::kNTPPrefVersion)); | 90 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); |
| 95 | 91 |
| 96 bool migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); | 92 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
| 97 ASSERT_TRUE(migrated); | 93 ASSERT_TRUE(migrated); |
| 98 ASSERT_EQ(NewTabUI::current_pref_version(), | 94 ASSERT_EQ(NewTabUI::current_pref_version(), |
| 99 prefs.GetInteger(prefs::kNTPPrefVersion)); | 95 prefs->GetInteger(prefs::kNTPPrefVersion)); |
| 100 | 96 |
| 101 migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); | 97 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
| 102 ASSERT_FALSE(migrated); | 98 ASSERT_FALSE(migrated); |
| 103 } | 99 } |
| 104 | 100 |
| 105 TEST_F(NewTabUITest, HomePageLink) { | 101 TEST_F(NewTabUITest, HomePageLink) { |
| 106 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 102 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 107 ASSERT_TRUE(browser.get()); | 103 ASSERT_TRUE(browser.get()); |
| 108 | 104 |
| 109 ASSERT_TRUE( | 105 ASSERT_TRUE( |
| 110 browser->SetBooleanPreference(prefs::kHomePageIsNewTabPage, false)); | 106 browser->SetBooleanPreference(prefs::kHomePageIsNewTabPage, false)); |
| 111 | 107 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 L"})()" | 157 L"})()" |
| 162 L")", | 158 L")", |
| 163 &has_class)); | 159 &has_class)); |
| 164 ASSERT_TRUE(has_class); | 160 ASSERT_TRUE(has_class); |
| 165 | 161 |
| 166 bool is_home_page; | 162 bool is_home_page; |
| 167 ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage, | 163 ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage, |
| 168 &is_home_page)); | 164 &is_home_page)); |
| 169 ASSERT_TRUE(is_home_page); | 165 ASSERT_TRUE(is_home_page); |
| 170 } | 166 } |
| OLD | NEW |