OLD | NEW |
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 "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/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 16 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
17 #include "chrome/browser/bookmarks/bookmark_model.h" | 17 #include "chrome/browser/bookmarks/bookmark_model.h" |
18 #include "chrome/browser/importer/firefox2_importer.h" | 18 #include "chrome/browser/importer/firefox2_importer.h" |
19 #include "chrome/test/base/testing_browser_process_test.h" | |
20 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
21 #include "content/browser/browser_thread.h" | 20 #include "content/browser/browser_thread.h" |
22 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/gfx/codec/png_codec.h" | 24 #include "ui/gfx/codec/png_codec.h" |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 static const int kIconWidth = 16; | 28 static const int kIconWidth = 16; |
30 static const int kIconHeight = 16; | 29 static const int kIconHeight = 16; |
31 | 30 |
32 void MakeTestSkBitmap(int w, int h, SkBitmap* bmp) { | 31 void MakeTestSkBitmap(int w, int h, SkBitmap* bmp) { |
33 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 32 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
34 bmp->allocPixels(); | 33 bmp->allocPixels(); |
35 | 34 |
36 uint32_t* src_data = bmp->getAddr32(0, 0); | 35 uint32_t* src_data = bmp->getAddr32(0, 0); |
37 for (int i = 0; i < w * h; i++) { | 36 for (int i = 0; i < w * h; i++) { |
38 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); |
39 } | 38 } |
40 } | 39 } |
41 | 40 |
42 } // namespace | 41 } // namespace |
43 | 42 |
44 class BookmarkHTMLWriterTest : public TestingBrowserProcessTest { | 43 class BookmarkHTMLWriterTest : public testing::Test { |
45 protected: | 44 protected: |
46 virtual void SetUp() { | 45 virtual void SetUp() { |
47 TestingBrowserProcessTest::SetUp(); | 46 testing::Test::SetUp(); |
48 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 47 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
49 path_ = temp_dir_.path().AppendASCII("bookmarks.html"); | 48 path_ = temp_dir_.path().AppendASCII("bookmarks.html"); |
50 } | 49 } |
51 | 50 |
52 // Converts a BookmarkEntry to a string suitable for assertion testing. | 51 // Converts a BookmarkEntry to a string suitable for assertion testing. |
53 string16 BookmarkEntryToString(const ProfileWriter::BookmarkEntry& entry) { | 52 string16 BookmarkEntryToString(const ProfileWriter::BookmarkEntry& entry) { |
54 string16 result; | 53 string16 result; |
55 result.append(ASCIIToUTF16("on_toolbar=")); | 54 result.append(ASCIIToUTF16("on_toolbar=")); |
56 if (entry.in_toolbar) | 55 if (entry.in_toolbar) |
57 result.append(ASCIIToUTF16("true")); | 56 result.append(ASCIIToUTF16("true")); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 bookmark_folder_name, string16(), string16()); | 255 bookmark_folder_name, string16(), string16()); |
257 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 256 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
258 string16(), string16(), string16()); | 257 string16(), string16(), string16()); |
259 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 258 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
260 string16(), string16(), string16()); | 259 string16(), string16(), string16()); |
261 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 260 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
262 f3_title, f4_title, string16()); | 261 f3_title, f4_title, string16()); |
263 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, | 262 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, |
264 string16(), string16(), string16()); | 263 string16(), string16(), string16()); |
265 } | 264 } |
OLD | NEW |