Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1299)

Unified Diff: chrome/browser/user_style_sheet_watcher_unittest.cc

Issue 660349: First cut at custom user style sheets. (Closed)
Patch Set: compile Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/user_style_sheet_watcher.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/user_style_sheet_watcher_unittest.cc
diff --git a/chrome/browser/user_style_sheet_watcher_unittest.cc b/chrome/browser/user_style_sheet_watcher_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3e5932ea3e9fce64ed30c075711915139bb108de
--- /dev/null
+++ b/chrome/browser/user_style_sheet_watcher_unittest.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/user_style_sheet_watcher.h"
+
+#include "base/base64.h"
+#include "base/file_util.h"
+#include "base/message_loop.h"
+#include "base/scoped_temp_dir.h"
+#include "base/string_util.h"
+#include "chrome/browser/chrome_thread.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(UserStyleSheetWatcherTest, StyleLoad) {
+ ScopedTempDir dir;
+ ASSERT_TRUE(dir.CreateUniqueTempDir());
+
+ std::string css_file_contents = "a { color: green; }";
+ FilePath style_sheet_file = dir.path().AppendASCII("User StyleSheets")
+ .AppendASCII("Custom.css");
+ file_util::CreateDirectory(style_sheet_file.DirName());
+ ASSERT_TRUE(file_util::WriteFile(style_sheet_file,
+ css_file_contents.data(), css_file_contents.length()));
+
+ scoped_refptr<UserStyleSheetWatcher> style_sheet_watcher =
+ new UserStyleSheetWatcher(dir.path());
+ MessageLoop loop;
+ ChromeThread ui_thread(ChromeThread::UI, &loop);
+ ChromeThread file_thread(ChromeThread::FILE, &loop);
+ style_sheet_watcher->Init();
+
+ loop.RunAllPending();
+
+ GURL result_url = style_sheet_watcher->user_style_sheet();
+ std::string result = result_url.spec();
+ std::string prefix = "data:text/css;charset=utf-8;base64,";
+ EXPECT_TRUE(StartsWithASCII(result, prefix, true));
+ result = result.substr(prefix.length());
+ std::string decoded;
+ EXPECT_TRUE(base::Base64Decode(result, &decoded));
+ EXPECT_EQ(css_file_contents, decoded);
+}
« no previous file with comments | « chrome/browser/user_style_sheet_watcher.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698