summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 00:20:45 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 00:20:45 +0000
commitfbc61139d748b9f81a89d7316cc29db1b7756665 (patch)
tree7f037423ad7cde84413bc772843a33739149883a
parentf4ea11288982f7b94ad7a7780cf0aa1a08e29509 (diff)
downloadchromium_src-fbc61139d748b9f81a89d7316cc29db1b7756665.zip
chromium_src-fbc61139d748b9f81a89d7316cc29db1b7756665.tar.gz
chromium_src-fbc61139d748b9f81a89d7316cc29db1b7756665.tar.bz2
Have UI tests use a profile where the dates in the segment_usage
table are current. By default, the NTP only uses data from the last 90 days, but the generated profile was created back in late 2008. Manually migrate the dates before launching chrome. This will probably impact the NTP perf tests, but it should give us a more realistic baseline. BUG=24369 TBR=brettw (Take 3 at landing this patch, this time with the proper fix for non-existent History files). Review URL: http://codereview.chromium.org/264053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28924 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/ui/ui_test.cc28
-rw-r--r--chrome/test/ui/ui_test.h9
2 files changed, 33 insertions, 4 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index aa7ec23..cc53886 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);
+}
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 177e5d8..165d9e5 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -19,9 +19,6 @@
#include "build/build_config.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#endif
#include <string>
#include "base/command_line.h"
@@ -287,7 +284,6 @@ class UITest : public testing::Test {
bool need_equal,
bool delete_generated_file);
- public:
// Get/Set a flag to run the renderer in process when running the
// tests.
static bool in_process_renderer() { return in_process_renderer_; }
@@ -531,6 +527,11 @@ class UITest : public testing::Test {
bool wait,
base::ProcessHandle* process);
+ // We want to have a current history database when we start the browser so
+ // things like the NTP will have thumbnails. This method updates the dates
+ // in the history to be more recent.
+ void UpdateHistoryDates();
+
base::Time test_start_time_; // Time the test was started
// (so we can check for new crash dumps)
static bool no_sandbox_;