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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/user_style_sheet_watcher.h"
6
7 #include "base/base64.h"
8 #include "base/file_util.h"
9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h"
11 #include "base/string_util.h"
12 #include "chrome/browser/chrome_thread.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 TEST(UserStyleSheetWatcherTest, StyleLoad) {
16 ScopedTempDir dir;
17 ASSERT_TRUE(dir.CreateUniqueTempDir());
18
19 std::string css_file_contents = "a { color: green; }";
20 FilePath style_sheet_file = dir.path().AppendASCII("User StyleSheets")
21 .AppendASCII("Custom.css");
22 file_util::CreateDirectory(style_sheet_file.DirName());
23 ASSERT_TRUE(file_util::WriteFile(style_sheet_file,
24 css_file_contents.data(), css_file_contents.length()));
25
26 scoped_refptr<UserStyleSheetWatcher> style_sheet_watcher =
27 new UserStyleSheetWatcher(dir.path());
28 MessageLoop loop;
29 ChromeThread ui_thread(ChromeThread::UI, &loop);
30 ChromeThread file_thread(ChromeThread::FILE, &loop);
31 style_sheet_watcher->Init();
32
33 loop.RunAllPending();
34
35 GURL result_url = style_sheet_watcher->user_style_sheet();
36 std::string result = result_url.spec();
37 std::string prefix = "data:text/css;charset=utf-8;base64,";
38 EXPECT_TRUE(StartsWithASCII(result, prefix, true));
39 result = result.substr(prefix.length());
40 std::string decoded;
41 EXPECT_TRUE(base::Base64Decode(result, &decoded));
42 EXPECT_EQ(css_file_contents, decoded);
43 }
OLDNEW
« 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