summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-15 16:33:42 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-15 16:33:42 +0000
commit3e9996e8b7f2e53c71a205852feeb16012ad43e5 (patch)
treef774509571cc7f8beb28476ada1f3b763646d2c1 /chrome/test
parent98a4a3ec81fc455480e745cb32e94fa2c4f904a6 (diff)
downloadchromium_src-3e9996e8b7f2e53c71a205852feeb16012ad43e5.zip
chromium_src-3e9996e8b7f2e53c71a205852feeb16012ad43e5.tar.gz
chromium_src-3e9996e8b7f2e53c71a205852feeb16012ad43e5.tar.bz2
Fix startup tests with complex theme.
BUG= http://crbug.com/18767 TEST= none Review URL: http://codereview.chromium.org/165478 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/profiles/complex_theme/Default/PreferencesTemplate64
-rw-r--r--chrome/test/startup/feature_startup_test.cc2
-rw-r--r--chrome/test/startup/startup_test.cc28
-rw-r--r--chrome/test/ui/ui_test.cc40
-rw-r--r--chrome/test/ui/ui_test.h5
5 files changed, 127 insertions, 12 deletions
diff --git a/chrome/test/data/profiles/complex_theme/Default/PreferencesTemplate b/chrome/test/data/profiles/complex_theme/Default/PreferencesTemplate
new file mode 100644
index 0000000..227f142
--- /dev/null
+++ b/chrome/test/data/profiles/complex_theme/Default/PreferencesTemplate
@@ -0,0 +1,64 @@
+{
+ "download": {
+ "directory_upgrade": true,
+ "extensions_to_open": ""
+ },
+ "extensions": {
+ "autoupdate": {
+ "next_check": "12894520286433189"
+ },
+ "settings": {
+ "mblmlcbknbnfebdfjnolmcapmdofhmme": {
+ "location": 1,
+ "path": "mblmlcbknbnfebdfjnolmcapmdofhmme\\1.1",
+ "state": 1
+ }
+ },
+ "theme": {
+ "colors": {
+ "bookmark_text": [ 0, 0, 0 ],
+ "frame": [ 57, 137, 194 ],
+ "frame_inactive": [ 155, 196, 224 ],
+ "frame_incognito": [ 68, 90, 106 ],
+ "frame_incognito_inactive": [ 118, 156, 183 ],
+ "ntp_background": [ 57, 137, 194 ],
+ "ntp_link": [ 0, 0, 0 ],
+ "ntp_section": [ 131, 138, 146, 0.8 ],
+ "ntp_section_link": [ 255, 255, 255 ],
+ "ntp_section_text": [ 255, 255, 255 ],
+ "ntp_text": [ 0, 0, 0 ],
+ "tab_background_text": [ 0, 0, 0 ],
+ "tab_text": [ 0, 0, 0 ],
+ "toolbar": [ 204, 208, 212 ]
+ },
+ "id": "mblmlcbknbnfebdfjnolmcapmdofhmme",
+ "images": {
+ "theme_button_background": "$1/Default/Extensions/mblmlcbknbnfebdfjnolmcapmdofhmme/1.1/i/agxjaHJvbWV0aGVtZXNyDAsSBEZpbGUYwsgCDA",
+ "theme_frame": "$1/Default/Extensions/mblmlcbknbnfebdfjnolmcapmdofhmme/1.1/i/agxjaHJvbWV0aGVtZXNyDAsSBEZpbGUYw8gCDA",
+ "theme_ntp_background": "$1/Default/Extensions/mblmlcbknbnfebdfjnolmcapmdofhmme/1.1/i/agxjaHJvbWV0aGVtZXNyDAsSBEZpbGUYj9gCDA",
+ "theme_tab_background": "$1/Default/Extensions/mblmlcbknbnfebdfjnolmcapmdofhmme/1.1/i/agxjaHJvbWV0aGVtZXNyDAsSBEZpbGUY_c8CDA",
+ "theme_toolbar": "$1/Default/Extensions/mblmlcbknbnfebdfjnolmcapmdofhmme/1.1/i/agxjaHJvbWV0aGVtZXNyDAsSBEZpbGUYnMgCDA",
+ "theme_window_control_background": "$1/Default/Extensions/mblmlcbknbnfebdfjnolmcapmdofhmme/1.1/i/agxjaHJvbWV0aGVtZXNyDAsSBEZpbGUYjNgCDA"
+ },
+ "properties": {
+ "ntp_background_alignment": "top",
+ "ntp_background_repeat": "no-repeat"
+ },
+ "tints": {
+ "buttons": [ 0.6, 0.553, 0.5 ]
+ }
+ }
+ },
+ "profile": {
+ "exited_cleanly": true,
+ "id": "not-signed-in",
+ "name": "Not Signed In",
+ "nickname": "not-signed-in"
+ },
+ "session": {
+ "urls_to_restore_on_startup": [ ]
+ },
+ "spellcheck": {
+ "dictionary": "en-US"
+ }
+}
diff --git a/chrome/test/startup/feature_startup_test.cc b/chrome/test/startup/feature_startup_test.cc
index 3e4dddc..7efe921 100644
--- a/chrome/test/startup/feature_startup_test.cc
+++ b/chrome/test/startup/feature_startup_test.cc
@@ -43,6 +43,8 @@ class NewTabUIStartupTest : public UITest {
// we should report cold timings.
void RunStartupTest(const char* label, bool want_warm, bool important,
int profile_type) {
+ profile_type_ = profile_type;
+
// Install the location of the test profile file.
set_template_user_data(UITest::ComputeTypicalUserDataSource(
profile_type).ToWStringHack());
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc
index 7a187de..59908a8 100644
--- a/chrome/test/startup/startup_test.cc
+++ b/chrome/test/startup/startup_test.cc
@@ -29,6 +29,15 @@ class StartupTest : public UITest {
void RunStartupTest(const char* graph, const char* trace,
bool test_cold, bool important, int profile_type) {
+ profile_type_ = profile_type;
+
+ // Sets the profile data for the run. For now, this is only used for
+ // the complex theme test.
+ if (profile_type == UITest::COMPLEX_THEME) {
+ set_template_user_data(UITest::ComputeTypicalUserDataSource(
+ profile_type).ToWStringHack());
+ }
+
const int kNumCyclesMax = 20;
int numCycles = kNumCyclesMax;
// It's ok for unit test code to use getenv(), isn't it?
@@ -64,13 +73,6 @@ class StartupTest : public UITest {
NOTIMPLEMENTED() << "gears not enabled yet";
#endif
}
-
- // Sets the profile data for the run. For now, this is only used for
- // the complex theme test.
- if (profile_type == UITest::COMPLEX_THEME)
- set_template_user_data(UITest::ComputeTypicalUserDataSource(
- profile_type).ToWStringHack());
-
UITest::SetUp();
TimeTicks end_time = TimeTicks::Now();
timings[i] = end_time - browser_launch_time_;
@@ -83,6 +85,10 @@ class StartupTest : public UITest {
// Re-use the profile data after first run so that the noise from
// creating databases doesn't impact all the runs.
clear_profile_ = false;
+ // Destroy template_user_data_ for complex theme so we don't try to
+ // rewrite each time through.
+ if (profile_type == UITest::COMPLEX_THEME)
+ set_template_user_data(L"");
}
}
@@ -161,9 +167,9 @@ TEST_F(StartupFileTest, PerfColdGears) {
}
#endif
-//TEST_F(StartupTest, PerfColdComplexTheme) {
-// RunStartupTest("warm", "t-theme", false /* warm */,
-// false /* not important */, UITest::COMPLEX_THEME);
-//}
+TEST_F(StartupTest, PerfColdComplexTheme) {
+ RunStartupTest("warm", "t-theme", false /* warm */,
+ false /* not important */, UITest::COMPLEX_THEME);
+}
} // namespace
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 69de19a..cc768e9 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -97,6 +97,7 @@ UITest::UITest()
include_testing_id_(true),
use_existing_browser_(default_use_existing_browser_),
enable_file_cookies_(true),
+ profile_type_(UITest::DEFAULT_THEME),
test_start_time_(base::Time::NowFromSystemTime()),
command_execution_timeout_ms_(kMaxTestExecutionTime),
action_timeout_ms_(kWaitForActionMsec),
@@ -307,7 +308,7 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
chrome::kBrowserProcessExecutablePath));
CommandLine command_line(command.ToWStringHack());
- // Add any explict command line flags passed to the process.
+ // Add any explicit command line flags passed to the process.
std::wstring extra_chrome_flags =
CommandLine::ForCurrentProcess()->GetSwitchValue(kExtraChromeFlagsSwitch);
if (!extra_chrome_flags.empty()) {
@@ -423,6 +424,11 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(
template_user_data_,
user_data_dir_.ToWStringHack()));
+ // If we're using the complex theme data, we need to write the
+ // user_data_dir_ to our preferences file.
+ if (profile_type_ == UITest::COMPLEX_THEME) {
+ RewritePreferencesFile(user_data_dir_);
+ }
}
browser_launch_time_ = TimeTicks::Now();
@@ -965,6 +971,38 @@ bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) {
}
// static
+void UITest::RewritePreferencesFile(const FilePath& user_data_dir) {
+ const FilePath pref_template_path(
+ user_data_dir.AppendASCII("Default").AppendASCII("PreferencesTemplate"));
+ const FilePath pref_path(
+ user_data_dir.AppendASCII("Default").AppendASCII("Preferences"));
+
+ // Read in preferences template.
+ std::string pref_string;
+ EXPECT_TRUE(file_util::ReadFileToString(pref_template_path, &pref_string));
+ string16 format_string = ASCIIToUTF16(pref_string);
+
+ // Make sure temp directory has the proper format for writing to prefs file.
+#if defined(OS_POSIX)
+ std::wstring user_data_dir_w(ASCIIToWide(user_data_dir.value()));
+#elif defined(OS_WIN)
+ std::wstring user_data_dir_w(user_data_dir.value());
+ // In Windows, the FilePath will write '\' for the path separators; change
+ // these to a separator that won't trigger escapes.
+ std::replace(user_data_dir_w.begin(),
+ user_data_dir_w.end(), '\\', '/');
+#endif
+
+ // Rewrite prefs file.
+ std::vector<string16> subst;
+ subst.push_back(WideToUTF16(user_data_dir_w));
+ const std::string prefs_string =
+ UTF16ToASCII(ReplaceStringPlaceholders(format_string, subst, NULL));
+ EXPECT_TRUE(file_util::WriteFile(pref_path, prefs_string.c_str(),
+ prefs_string.size()));
+}
+
+// static
FilePath UITest::ComputeTypicalUserDataSource(int profile_type) {
FilePath source_history_file;
EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA,
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index a512fb7..2b49f82 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -342,6 +342,9 @@ class UITest : public testing::Test {
// for testing.
static FilePath ComputeTypicalUserDataSource(int profile_type);
+ // Rewrite the preferences file to point to the proper image directory.
+ static void RewritePreferencesFile(const FilePath& user_data_dir);
+
// Called by some tests that wish to have a base profile to start from. This
// "user data directory" (containing one or more profiles) will be recursively
// copied into the user data directory for the test and the files will be
@@ -479,6 +482,8 @@ class UITest : public testing::Test {
bool use_existing_browser_; // Duplicate of the static version.
// Default value comes from static.
bool enable_file_cookies_; // Enable file cookies, default is true.
+ int profile_type_; // Are we using a profile with a
+ // complex theme?
private:
base::Time test_start_time_; // Time the test was started