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

Side by Side Diff: chrome/browser/user_style_sheet_watcher_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/themes/browser_theme_provider.cc ('k') | chrome/common/database_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/user_style_sheet_watcher.h" 5 #include "chrome/browser/user_style_sheet_watcher.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/browser_thread.h" 12 #include "chrome/browser/browser_thread.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 TEST(UserStyleSheetWatcherTest, StyleLoad) { 15 TEST(UserStyleSheetWatcherTest, StyleLoad) {
16 ScopedTempDir dir; 16 ScopedTempDir dir;
17 ASSERT_TRUE(dir.CreateUniqueTempDir()); 17 ASSERT_TRUE(dir.CreateUniqueTempDir());
18 18
19 std::string css_file_contents = "a { color: green; }"; 19 std::string css_file_contents = "a { color: green; }";
20 FilePath style_sheet_file = dir.path().AppendASCII("User StyleSheets") 20 FilePath style_sheet_file = dir.path().AppendASCII("User StyleSheets")
21 .AppendASCII("Custom.css"); 21 .AppendASCII("Custom.css");
22 file_util::CreateDirectory(style_sheet_file.DirName()); 22 file_util::CreateDirectory(style_sheet_file.DirName());
23 ASSERT_TRUE(file_util::WriteFile(style_sheet_file, 23 ASSERT_TRUE(file_util::WriteFile(style_sheet_file,
24 css_file_contents.data(), css_file_contents.length())); 24 css_file_contents.data(), css_file_contents.length()));
25 25
26 scoped_refptr<UserStyleSheetWatcher> style_sheet_watcher = 26 scoped_refptr<UserStyleSheetWatcher> style_sheet_watcher(
27 new UserStyleSheetWatcher(dir.path()); 27 new UserStyleSheetWatcher(dir.path()));
28 MessageLoop loop; 28 MessageLoop loop;
29 BrowserThread ui_thread(BrowserThread::UI, &loop); 29 BrowserThread ui_thread(BrowserThread::UI, &loop);
30 BrowserThread file_thread(BrowserThread::FILE, &loop); 30 BrowserThread file_thread(BrowserThread::FILE, &loop);
31 style_sheet_watcher->Init(); 31 style_sheet_watcher->Init();
32 32
33 loop.RunAllPending(); 33 loop.RunAllPending();
34 34
35 GURL result_url = style_sheet_watcher->user_style_sheet(); 35 GURL result_url = style_sheet_watcher->user_style_sheet();
36 std::string result = result_url.spec(); 36 std::string result = result_url.spec();
37 std::string prefix = "data:text/css;charset=utf-8;base64,"; 37 std::string prefix = "data:text/css;charset=utf-8;base64,";
38 EXPECT_TRUE(StartsWithASCII(result, prefix, true)); 38 EXPECT_TRUE(StartsWithASCII(result, prefix, true));
39 result = result.substr(prefix.length()); 39 result = result.substr(prefix.length());
40 std::string decoded; 40 std::string decoded;
41 EXPECT_TRUE(base::Base64Decode(result, &decoded)); 41 EXPECT_TRUE(base::Base64Decode(result, &decoded));
42 EXPECT_EQ(css_file_contents, decoded); 42 EXPECT_EQ(css_file_contents, decoded);
43 style_sheet_watcher = NULL; 43 style_sheet_watcher = NULL;
44 } 44 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/browser_theme_provider.cc ('k') | chrome/common/database_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698