diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 20:08:33 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 20:08:33 +0000 |
commit | f5c172084ebace23f2c639a4d08cb13a98a0d336 (patch) | |
tree | 2515d15c1aeeab661dd65a86a1b35382c1443d08 /chrome/test/ui/ui_test.cc | |
parent | 67274c96843e6ecc7e299f6165c1ea2bb02f3361 (diff) | |
download | chromium_src-f5c172084ebace23f2c639a4d08cb13a98a0d336.zip chromium_src-f5c172084ebace23f2c639a4d08cb13a98a0d336.tar.gz chromium_src-f5c172084ebace23f2c639a4d08cb13a98a0d336.tar.bz2 |
Revert "Revert "Have UI tests use a profile where the dates in the segment_usage""
This re-lands commit r28844 with a fix to make sure the History database
exists before trying to update the dates.
TBR=brettw
Review URL: http://codereview.chromium.org/266066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui/ui_test.cc')
-rw-r--r-- | chrome/test/ui/ui_test.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index aa7ec23..3052646 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -7,6 +7,7 @@ #include <set> #include <vector> +#include "app/sql/connection.h" #include "base/base_switches.h" #include "base/command_line.h" #include "base/file_util.h" @@ -371,6 +372,9 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) { if (profile_type_ == UITest::COMPLEX_THEME) { RewritePreferencesFile(user_data_dir_); } + + // Update the history file to include recent dates. + UpdateHistoryDates(); } ASSERT_TRUE(LaunchBrowserHelper(arguments, use_existing_browser_, false, @@ -929,6 +933,7 @@ void UITest::RewritePreferencesFile(const FilePath& user_data_dir) { UTF16ToASCII(ReplaceStringPlaceholders(format_string, subst, NULL)); EXPECT_TRUE(file_util::WriteFile(pref_path, prefs_string.c_str(), prefs_string.size())); + file_util::EvictFileFromSystemCache(pref_path); } // static @@ -1148,3 +1153,26 @@ bool UITest::LaunchBrowserHelper(const CommandLine& arguments, return true; } + +void UITest::UpdateHistoryDates() { + // Migrate the times in the segment_usage table to yesterday so we get + // actual thumbnails on the NTP. + sql::Connection db; + FilePath history = + user_data_dir_.AppendASCII("Default").AppendASCII("History"); + // Not all test profiles have a history file. + if (!file_util::PathExists(history)) + return; + + ASSERT_TRUE(!db.Open(history)); + base::Time yesterday = base::Time::Now() - base::TimeDelta::FromDays(1); + std::string yesterday_str = Int64ToString(yesterday.ToInternalValue()); + std::string query = StringPrintf( + "UPDATE segment_usage " + "SET time_slot = %s " + "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);", + yesterday_str.c_str()); + ASSERT_TRUE(db.Execute(query.c_str())); + db.Close(); + file_util::EvictFileFromSystemCache(history); +} |