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 "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 10 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/common/pref_service.h" |
8 #include "chrome/test/automation/browser_proxy.h" | 12 #include "chrome/test/automation/browser_proxy.h" |
9 #include "chrome/test/automation/tab_proxy.h" | 13 #include "chrome/test/automation/tab_proxy.h" |
10 #include "chrome/test/automation/window_proxy.h" | 14 #include "chrome/test/automation/window_proxy.h" |
11 | 15 |
12 class NewTabUITest : public UITest { | 16 class NewTabUITest : public UITest { |
13 public: | 17 public: |
14 NewTabUITest() { | 18 NewTabUITest() { |
15 dom_automation_enabled_ = true; | 19 dom_automation_enabled_ = true; |
16 | 20 |
17 // Setup the DEFAULT_THEME profile (has fake history entries). | 21 // Setup the DEFAULT_THEME profile (has fake history entries). |
(...skipping 29 matching lines...) Expand all Loading... |
47 L"window.domAutomationController.send(" | 51 L"window.domAutomationController.send(" |
48 L"document.getElementsByClassName('filler').length)", | 52 L"document.getElementsByClassName('filler').length)", |
49 &filler_thumbnails_count)); | 53 &filler_thumbnails_count)); |
50 if (filler_thumbnails_count == 0) | 54 if (filler_thumbnails_count == 0) |
51 break; | 55 break; |
52 PlatformThread::Sleep(kWaitDuration); | 56 PlatformThread::Sleep(kWaitDuration); |
53 wait_time -= kWaitDuration; | 57 wait_time -= kWaitDuration; |
54 } | 58 } |
55 EXPECT_EQ(0, filler_thumbnails_count); | 59 EXPECT_EQ(0, filler_thumbnails_count); |
56 } | 60 } |
| 61 |
| 62 TEST_F(NewTabUITest, UpdateUserPrefsVersion) { |
| 63 PrefService prefs(FilePath(), NULL); |
| 64 |
| 65 // Does the migration |
| 66 NewTabUI::RegisterUserPrefs(&prefs); |
| 67 |
| 68 ASSERT_EQ(NewTabUI::current_pref_version(), |
| 69 prefs.GetInteger(prefs::kNTPPrefVersion)); |
| 70 |
| 71 // Reset the version |
| 72 prefs.ClearPref(prefs::kNTPPrefVersion); |
| 73 ASSERT_EQ(0, prefs.GetInteger(prefs::kNTPPrefVersion)); |
| 74 |
| 75 bool migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); |
| 76 ASSERT_TRUE(migrated); |
| 77 ASSERT_EQ(NewTabUI::current_pref_version(), |
| 78 prefs.GetInteger(prefs::kNTPPrefVersion)); |
| 79 |
| 80 migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); |
| 81 ASSERT_FALSE(migrated); |
| 82 } |
OLD | NEW |