OLD | NEW |
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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/i18n/time_formatting.h" | 14 #include "base/i18n/time_formatting.h" |
15 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 15 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
16 #include "chrome/browser/bookmarks/bookmark_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
17 #include "chrome/browser/browser_thread.h" | 17 #include "chrome/browser/browser_thread.h" |
18 #include "chrome/browser/importer/firefox2_importer.h" | 18 #include "chrome/browser/importer/firefox2_importer.h" |
| 19 #include "chrome/test/testing_browser_process_test.h" |
19 #include "chrome/test/testing_profile.h" | 20 #include "chrome/test/testing_profile.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/gfx/codec/png_codec.h" | 24 #include "ui/gfx/codec/png_codec.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 static const int kIconWidth = 16; | 28 static const int kIconWidth = 16; |
28 static const int kIconHeight = 16; | 29 static const int kIconHeight = 16; |
29 | 30 |
30 void MakeTestSkBitmap(int w, int h, SkBitmap* bmp) { | 31 void MakeTestSkBitmap(int w, int h, SkBitmap* bmp) { |
31 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 32 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
32 bmp->allocPixels(); | 33 bmp->allocPixels(); |
33 | 34 |
34 uint32_t* src_data = bmp->getAddr32(0, 0); | 35 uint32_t* src_data = bmp->getAddr32(0, 0); |
35 for (int i = 0; i < w * h; i++) { | 36 for (int i = 0; i < w * h; i++) { |
36 src_data[i] = SkPreMultiplyARGB(i % 255, i % 250, i % 245, i % 240); | 37 src_data[i] = SkPreMultiplyARGB(i % 255, i % 250, i % 245, i % 240); |
37 } | 38 } |
38 } | 39 } |
39 | 40 |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 class BookmarkHTMLWriterTest : public testing::Test { | 43 class BookmarkHTMLWriterTest : public TestingBrowserProcessTest { |
43 protected: | 44 protected: |
44 virtual void SetUp() { | 45 virtual void SetUp() { |
45 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); | 46 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); |
46 path_ = path_.AppendASCII("bookmarks.html"); | 47 path_ = path_.AppendASCII("bookmarks.html"); |
47 file_util::Delete(path_, true); | 48 file_util::Delete(path_, true); |
48 } | 49 } |
49 | 50 |
50 virtual void TearDown() { | 51 virtual void TearDown() { |
51 if (!path_.empty()) | 52 if (!path_.empty()) |
52 file_util::Delete(path_, true); | 53 file_util::Delete(path_, true); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 bookmark_folder_name, string16(), string16()); | 257 bookmark_folder_name, string16(), string16()); |
257 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4, | 258 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4, |
258 bookmark_folder_name, string16(), string16()); | 259 bookmark_folder_name, string16(), string16()); |
259 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 260 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
260 string16(), string16(), string16()); | 261 string16(), string16(), string16()); |
261 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 262 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
262 string16(), string16(), string16()); | 263 string16(), string16(), string16()); |
263 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 264 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
264 f3_title, f4_title, string16()); | 265 f3_title, f4_title, string16()); |
265 } | 266 } |
OLD | NEW |