| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
| 11 #include "chrome/browser/pref_service.h" | |
| 12 #include "chrome/browser/pref_value_store.h" | 11 #include "chrome/browser/pref_value_store.h" |
| 13 #include "chrome/common/json_pref_store.h" | 12 #include "chrome/common/json_pref_store.h" |
| 14 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/automation/browser_proxy.h" | 14 #include "chrome/test/automation/browser_proxy.h" |
| 16 #include "chrome/test/automation/tab_proxy.h" | 15 #include "chrome/test/automation/tab_proxy.h" |
| 17 #include "chrome/test/automation/window_proxy.h" | 16 #include "chrome/test/automation/window_proxy.h" |
| 17 #include "chrome/test/testing_pref_service.h" |
| 18 | 18 |
| 19 class NewTabUITest : public UITest { | 19 class NewTabUITest : public UITest { |
| 20 public: | 20 public: |
| 21 NewTabUITest() { | 21 NewTabUITest() { |
| 22 dom_automation_enabled_ = true; | 22 dom_automation_enabled_ = true; |
| 23 // Set home page to the empty string so that we can set the home page using | 23 // Set home page to the empty string so that we can set the home page using |
| 24 // preferences. | 24 // preferences. |
| 25 homepage_ = L""; | 25 homepage_ = L""; |
| 26 | 26 |
| 27 // Setup the DEFAULT_THEME profile (has fake history entries). | 27 // Setup the DEFAULT_THEME profile (has fake history entries). |
| (...skipping 40 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 FilePath user_prefs = FilePath(); | 78 scoped_ptr<PrefService> prefs(new TestingPrefService); |
| 79 scoped_ptr<PrefService> prefs( | |
| 80 PrefService::CreateUserPrefService(user_prefs)); | |
| 81 | 79 |
| 82 // Does the migration | 80 // Does the migration |
| 83 NewTabUI::RegisterUserPrefs(prefs.get()); | 81 NewTabUI::RegisterUserPrefs(prefs.get()); |
| 84 | 82 |
| 85 ASSERT_EQ(NewTabUI::current_pref_version(), | 83 ASSERT_EQ(NewTabUI::current_pref_version(), |
| 86 prefs->GetInteger(prefs::kNTPPrefVersion)); | 84 prefs->GetInteger(prefs::kNTPPrefVersion)); |
| 87 | 85 |
| 88 // Reset the version | 86 // Reset the version |
| 89 prefs->ClearPref(prefs::kNTPPrefVersion); | 87 prefs->ClearPref(prefs::kNTPPrefVersion); |
| 90 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); | 88 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 L"})()" | 155 L"})()" |
| 158 L")", | 156 L")", |
| 159 &has_class)); | 157 &has_class)); |
| 160 ASSERT_TRUE(has_class); | 158 ASSERT_TRUE(has_class); |
| 161 | 159 |
| 162 bool is_home_page; | 160 bool is_home_page; |
| 163 ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage, | 161 ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage, |
| 164 &is_home_page)); | 162 &is_home_page)); |
| 165 ASSERT_TRUE(is_home_page); | 163 ASSERT_TRUE(is_home_page); |
| 166 } | 164 } |
| 167 | |
| OLD | NEW |