summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-06 16:10:04 +0000
committerblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-06 16:10:04 +0000
commit23e63803fbf9a7aaf0a6107e36ea9c2ef6857d95 (patch)
treec49353f10b6052ccf376d0a79453514664fbe794
parent010a470359a8cea15e5f6cfbba2ef4a81e2713c2 (diff)
downloadchromium_src-23e63803fbf9a7aaf0a6107e36ea9c2ef6857d95.zip
chromium_src-23e63803fbf9a7aaf0a6107e36ea9c2ef6857d95.tar.gz
chromium_src-23e63803fbf9a7aaf0a6107e36ea9c2ef6857d95.tar.bz2
Componentize bookmarks_codec_unittest
Moves test_bookmark_client to the bookmarks component and componentizes bookmarks_codec_unittest. The latter entails moving data files to //components/test/data and accessing them from that location in the test. BUG=367839,367829 Review URL: https://codereview.chromium.org/269813006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268528 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--components/bookmarks/core/browser/bookmark_codec_unittest.cc (renamed from chrome/browser/bookmarks/bookmark_codec_unittest.cc)78
-rw-r--r--components/components_tests.gyp6
-rw-r--r--components/startup_metric_utils/startup_metric_utils.cc3
-rw-r--r--components/test/data/bookmarks/meta_info_as_string.json (renamed from chrome/test/data/bookmarks/meta_info_as_string.json)0
-rw-r--r--components/test/data/bookmarks/model_without_sync.json (renamed from chrome/test/data/bookmarks/model_without_sync.json)0
6 files changed, 51 insertions, 37 deletions
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index bfa13da..b4b4887 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -601,7 +601,6 @@
'browser/background/background_application_list_model_unittest.cc',
'browser/background/background_contents_service_unittest.cc',
'browser/background/background_mode_manager_unittest.cc',
- 'browser/bookmarks/bookmark_codec_unittest.cc',
'browser/bookmarks/bookmark_expanded_state_tracker_unittest.cc',
'browser/bookmarks/bookmark_html_writer_unittest.cc',
'browser/bookmarks/bookmark_index_unittest.cc',
diff --git a/chrome/browser/bookmarks/bookmark_codec_unittest.cc b/components/bookmarks/core/browser/bookmark_codec_unittest.cc
index 2e35d24..4321eb9 100644
--- a/chrome/browser/bookmarks/bookmark_codec_unittest.cc
+++ b/components/bookmarks/core/browser/bookmark_codec_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,6 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/common/chrome_paths.h"
#include "components/bookmarks/core/browser/bookmark_model.h"
#include "components/bookmarks/core/test/test_bookmark_client.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -33,6 +32,17 @@ const char kUrl4Url[] = "http://www.url4.com";
const char kFolder1Title[] = "folder1";
const char kFolder2Title[] = "folder2";
+const base::FilePath& GetTestDataDir() {
+ CR_DEFINE_STATIC_LOCAL(base::FilePath, dir, ());
+ if (dir.empty()) {
+ PathService::Get(base::DIR_SOURCE_ROOT, &dir);
+ dir = dir.AppendASCII("components");
+ dir = dir.AppendASCII("test");
+ dir = dir.AppendASCII("data");
+ }
+ return dir;
+}
+
// Helper to get a mutable bookmark node.
BookmarkNode* AsMutable(const BookmarkNode* node) {
return const_cast<BookmarkNode*>(node);
@@ -90,8 +100,8 @@ class BookmarkCodecTest : public testing::Test {
scoped_ptr<BookmarkModel> model(client_.CreateModel(false));
const BookmarkNode* bookmark_bar = model->bookmark_bar_node();
model->AddURL(bookmark_bar, 0, ASCIIToUTF16(kUrl1Title), GURL(kUrl1Url));
- const BookmarkNode* folder1 = model->AddFolder(bookmark_bar, 1,
- ASCIIToUTF16(kFolder1Title));
+ const BookmarkNode* folder1 =
+ model->AddFolder(bookmark_bar, 1, ASCIIToUTF16(kFolder1Title));
model->AddURL(folder1, 0, ASCIIToUTF16(kUrl2Title), GURL(kUrl2Url));
return model.release();
}
@@ -109,15 +119,15 @@ class BookmarkCodecTest : public testing::Test {
base::DictionaryValue* roots_d_value =
static_cast<base::DictionaryValue*>(roots);
base::Value* bb_value;
- ASSERT_TRUE(roots_d_value->Get(BookmarkCodec::kRootFolderNameKey,
- &bb_value));
+ ASSERT_TRUE(
+ roots_d_value->Get(BookmarkCodec::kRootFolderNameKey, &bb_value));
ASSERT_EQ(base::Value::TYPE_DICTIONARY, bb_value->GetType());
base::DictionaryValue* bb_d_value =
static_cast<base::DictionaryValue*>(bb_value);
base::Value* bb_children_value;
- ASSERT_TRUE(bb_d_value->Get(BookmarkCodec::kChildrenKey,
- &bb_children_value));
+ ASSERT_TRUE(
+ bb_d_value->Get(BookmarkCodec::kChildrenKey, &bb_children_value));
ASSERT_EQ(base::Value::TYPE_LIST, bb_children_value->GetType());
base::ListValue* bb_children_l_value =
@@ -155,12 +165,12 @@ class BookmarkCodecTest : public testing::Test {
bool result = codec->Decode(AsMutable(model->bookmark_bar_node()),
AsMutable(model->other_node()),
AsMutable(model->mobile_node()),
- &max_id, value);
+ &max_id,
+ value);
model->set_next_node_id(max_id);
- AsMutable(model->root_node())->
- SetMetaInfoMap(codec->model_meta_info_map());
- AsMutable(model->root_node())->
- set_sync_transaction_version(codec->model_sync_transaction_version());
+ AsMutable(model->root_node())->SetMetaInfoMap(codec->model_meta_info_map());
+ AsMutable(model->root_node())
+ ->set_sync_transaction_version(codec->model_sync_transaction_version());
return result;
}
@@ -225,8 +235,8 @@ TEST_F(BookmarkCodecTest, ChecksumEncodeDecodeTest) {
EXPECT_TRUE(value.get() != NULL);
std::string dec_checksum;
- scoped_ptr<BookmarkModel> decoded_model(DecodeHelper(
- *value.get(), enc_checksum, &dec_checksum, false));
+ scoped_ptr<BookmarkModel> decoded_model(
+ DecodeHelper(*value.get(), enc_checksum, &dec_checksum, false));
}
TEST_F(BookmarkCodecTest, ChecksumEncodeIdenticalModelsTest) {
@@ -261,13 +271,13 @@ TEST_F(BookmarkCodecTest, ChecksumManualEditTest) {
child1_value->SetString(BookmarkCodec::kNameKey, title + "1");
std::string dec_checksum;
- scoped_ptr<BookmarkModel> decoded_model1(DecodeHelper(
- *value.get(), enc_checksum, &dec_checksum, true));
+ scoped_ptr<BookmarkModel> decoded_model1(
+ DecodeHelper(*value.get(), enc_checksum, &dec_checksum, true));
// Undo the change and make sure the checksum is same as original.
child1_value->SetString(BookmarkCodec::kNameKey, title);
- scoped_ptr<BookmarkModel> decoded_model2(DecodeHelper(
- *value.get(), enc_checksum, &dec_checksum, false));
+ scoped_ptr<BookmarkModel> decoded_model2(
+ DecodeHelper(*value.get(), enc_checksum, &dec_checksum, false));
}
TEST_F(BookmarkCodecTest, ChecksumManualEditIDsTest) {
@@ -294,17 +304,17 @@ TEST_F(BookmarkCodecTest, ChecksumManualEditIDsTest) {
}
std::string dec_checksum;
- scoped_ptr<BookmarkModel> decoded_model(DecodeHelper(
- *value.get(), enc_checksum, &dec_checksum, true));
+ scoped_ptr<BookmarkModel> decoded_model(
+ DecodeHelper(*value.get(), enc_checksum, &dec_checksum, true));
ExpectIDsUnique(decoded_model.get());
// add a few extra nodes to bookmark model and make sure IDs are still uniuqe.
const BookmarkNode* bb_node = decoded_model->bookmark_bar_node();
- decoded_model->AddURL(bb_node, 0, ASCIIToUTF16("new url1"),
- GURL("http://newurl1.com"));
- decoded_model->AddURL(bb_node, 0, ASCIIToUTF16("new url2"),
- GURL("http://newurl2.com"));
+ decoded_model->AddURL(
+ bb_node, 0, ASCIIToUTF16("new url1"), GURL("http://newurl1.com"));
+ decoded_model->AddURL(
+ bb_node, 0, ASCIIToUTF16("new url2"), GURL("http://newurl2.com"));
ExpectIDsUnique(decoded_model.get());
}
@@ -344,9 +354,8 @@ TEST_F(BookmarkCodecTest, PersistIDsTest) {
TEST_F(BookmarkCodecTest, CanDecodeModelWithoutMobileBookmarks) {
base::FilePath test_data_directory;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory));
- base::FilePath test_file = test_data_directory.AppendASCII(
- "bookmarks/model_without_sync.json");
+ base::FilePath test_file =
+ GetTestDataDir().AppendASCII("bookmarks/model_without_sync.json");
ASSERT_TRUE(base::PathExists(test_file));
JSONFileValueSerializer serializer(test_file);
@@ -388,8 +397,8 @@ TEST_F(BookmarkCodecTest, EncodeAndDecodeMetaInfo) {
// Add meta info and encode.
scoped_ptr<BookmarkModel> model(CreateTestModel1());
model->SetNodeMetaInfo(model->root_node(), "model_info", "value1");
- model->SetNodeMetaInfo(model->bookmark_bar_node()->GetChild(0),
- "node_info", "value2");
+ model->SetNodeMetaInfo(
+ model->bookmark_bar_node()->GetChild(0), "node_info", "value2");
std::string checksum;
scoped_ptr<base::Value> value(EncodeHelper(model.get(), &checksum));
ASSERT_TRUE(value.get() != NULL);
@@ -432,9 +441,8 @@ TEST_F(BookmarkCodecTest, EncodeAndDecodeSyncTransactionVersion) {
// way meta info is stored.
TEST_F(BookmarkCodecTest, CanDecodeMetaInfoAsString) {
base::FilePath test_data_directory;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory));
- base::FilePath test_file = test_data_directory.AppendASCII(
- "bookmarks/meta_info_as_string.json");
+ base::FilePath test_file =
+ GetTestDataDir().AppendASCII("bookmarks/meta_info_as_string.json");
ASSERT_TRUE(base::PathExists(test_file));
JSONFileValueSerializer serializer(test_file);
@@ -456,8 +464,8 @@ TEST_F(BookmarkCodecTest, CanDecodeMetaInfoAsString) {
std::string meta_value;
EXPECT_FALSE(
model->root_node()->GetMetaInfo(kSyncTransactionVersionKey, &meta_value));
- EXPECT_FALSE(bbn->GetChild(1)->GetMetaInfo(kSyncTransactionVersionKey,
- &meta_value));
+ EXPECT_FALSE(
+ bbn->GetChild(1)->GetMetaInfo(kSyncTransactionVersionKey, &meta_value));
EXPECT_TRUE(bbn->GetChild(0)->GetMetaInfo(kNormalKey, &meta_value));
EXPECT_EQ("value", meta_value);
EXPECT_TRUE(bbn->GetChild(1)->GetMetaInfo(kNormalKey, &meta_value));
diff --git a/components/components_tests.gyp b/components/components_tests.gyp
index 43fbbef..77be272 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -63,6 +63,7 @@
'autofill/core/common/form_field_data_unittest.cc',
'autofill/core/common/password_form_fill_data_unittest.cc',
'autofill/core/common/save_password_progress_logger_unittest.cc',
+ 'bookmarks/core/browser/bookmark_codec_unittest.cc',
'captive_portal/captive_portal_detector_unittest.cc',
'cloud_devices/common/cloud_devices_urls_unittest.cc',
'cloud_devices/common/printer_description_unittest.cc',
@@ -198,6 +199,10 @@
'components_strings.gyp:components_strings',
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber',
+ # Dependencies of bookmarks
+ 'components.gyp:bookmarks_core_browser',
+ 'components.gyp:bookmarks_core_test_support',
+
# Dependencies of captive_portal
'components.gyp:captive_portal_test_support',
'../net/net.gyp:net_test_support',
@@ -323,6 +328,7 @@
['include', '^test/run_all_unittests\\.cc$'],
['include', '^auto_login_parser/'],
['include', '^autofill/core/'],
+ ['include', '^bookmarks/'],
['include', '^data_reduction_proxy/'],
['include', '^dom_distiller/'],
['include', '^json_schema/'],
diff --git a/components/startup_metric_utils/startup_metric_utils.cc b/components/startup_metric_utils/startup_metric_utils.cc
index beb41cd..5f60e95 100644
--- a/components/startup_metric_utils/startup_metric_utils.cc
+++ b/components/startup_metric_utils/startup_metric_utils.cc
@@ -149,7 +149,8 @@ void OnBrowserStartupComplete(bool is_first_run) {
// CurrentProcessInfo::CreationTime() is currently only implemented on some
// platforms.
-#if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX)
+#if (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) || \
+ defined(OS_LINUX)
// Record timings between process creation, the main() in the executable being
// reached and the main() in the shared library being reached.
scoped_ptr<base::Environment> env(base::Environment::Create());
diff --git a/chrome/test/data/bookmarks/meta_info_as_string.json b/components/test/data/bookmarks/meta_info_as_string.json
index 3f55d72..3f55d72 100644
--- a/chrome/test/data/bookmarks/meta_info_as_string.json
+++ b/components/test/data/bookmarks/meta_info_as_string.json
diff --git a/chrome/test/data/bookmarks/model_without_sync.json b/components/test/data/bookmarks/model_without_sync.json
index 517f834..517f834 100644
--- a/chrome/test/data/bookmarks/model_without_sync.json
+++ b/components/test/data/bookmarks/model_without_sync.json