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

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

Issue 7744039: Switch ChromeTestSuite to the same convention as ContentTestSuite: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixing Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
15 #include "content/browser/browser_thread.h" 15 #include "content/browser/browser_thread.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 TEST(UserStyleSheetWatcherTest, StyleLoad) { 18 TEST(UserStyleSheetWatcherTest, StyleLoad) {
19 ScopedTestingBrowserProcess browser_process;
20
21 ScopedTempDir dir; 19 ScopedTempDir dir;
22 ASSERT_TRUE(dir.CreateUniqueTempDir()); 20 ASSERT_TRUE(dir.CreateUniqueTempDir());
23 21
24 std::string css_file_contents = "a { color: green; }"; 22 std::string css_file_contents = "a { color: green; }";
25 FilePath style_sheet_file = dir.path().AppendASCII("User StyleSheets") 23 FilePath style_sheet_file = dir.path().AppendASCII("User StyleSheets")
26 .AppendASCII("Custom.css"); 24 .AppendASCII("Custom.css");
27 file_util::CreateDirectory(style_sheet_file.DirName()); 25 file_util::CreateDirectory(style_sheet_file.DirName());
28 ASSERT_TRUE(file_util::WriteFile(style_sheet_file, 26 ASSERT_TRUE(file_util::WriteFile(style_sheet_file,
29 css_file_contents.data(), css_file_contents.length())); 27 css_file_contents.data(), css_file_contents.length()));
30 28
(...skipping 17 matching lines...) Expand all
48 46
49 GURL result_url = style_sheet_watcher->user_style_sheet(); 47 GURL result_url = style_sheet_watcher->user_style_sheet();
50 std::string result = result_url.spec(); 48 std::string result = result_url.spec();
51 std::string prefix = "data:text/css;charset=utf-8;base64,"; 49 std::string prefix = "data:text/css;charset=utf-8;base64,";
52 ASSERT_TRUE(StartsWithASCII(result, prefix, true)); 50 ASSERT_TRUE(StartsWithASCII(result, prefix, true));
53 result = result.substr(prefix.length()); 51 result = result.substr(prefix.length());
54 std::string decoded; 52 std::string decoded;
55 ASSERT_TRUE(base::Base64Decode(result, &decoded)); 53 ASSERT_TRUE(base::Base64Decode(result, &decoded));
56 ASSERT_EQ(css_file_contents, decoded); 54 ASSERT_EQ(css_file_contents, decoded);
57 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698