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

Unified Diff: chrome/browser/extensions/extension_sync_data_unittest.cc

Issue 7564037: Apps/Extensions Sync refactoring -- delete most of the old glue, implement new sync API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Release build warning :-/ 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_sync_data_unittest.cc
diff --git a/chrome/browser/extensions/extension_sync_data_unittest.cc b/chrome/browser/extensions/extension_sync_data_unittest.cc
index e08d1845ffebdec62d53a19af54768446b3d77bc..16dce1718d22fefc318743e4ec248ed634504e20 100644
--- a/chrome/browser/extensions/extension_sync_data_unittest.cc
+++ b/chrome/browser/extensions/extension_sync_data_unittest.cc
@@ -6,81 +6,86 @@
#include "base/memory/scoped_ptr.h"
#include "base/version.h"
+#include "chrome/browser/sync/protocol/app_specifics.pb.h"
+#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-class ExtensionSyncDataTest : public testing::Test {
-};
-
-bool ExtensionSyncDataEqual(const ExtensionSyncData& a,
- const ExtensionSyncData& b) {
- return
- (a.id == b.id) &&
- (a.enabled == b.enabled) &&
- (a.incognito_enabled == b.incognito_enabled) &&
- (a.version.Equals(b.version)) &&
- (a.update_url == b.update_url) &&
- (a.name == b.name);
-}
+#if defined(OS_WIN)
+const FilePath::CharType kExtensionFilePath[] = FILE_PATH_LITERAL("c:\\foo");
+#elif defined(OS_POSIX)
+const FilePath::CharType kExtensionFilePath[] = FILE_PATH_LITERAL("/foo");
+#endif
-TEST_F(ExtensionSyncDataTest, MergeOlder) {
- ExtensionSyncData data;
- data.id = "id";
- data.enabled = true;
- data.incognito_enabled = false;
- {
- scoped_ptr<Version> version(Version::GetVersionFromString("1.2.0.0"));
- data.version = *version;
- }
- data.update_url = GURL("http://www.old.com");
- data.name = "data";
+const char kValidId[] = "abcdefghijklmnopabcdefghijklmnop";
+const char kValidVersion[] = "0.0.0.0";
+const char kVersion1[] = "1.0.0.1";
+const char kVersion2[] = "1.0.1.0";
+const char kVersion3[] = "1.1.0.0";
+const char kValidUpdateUrl1[] =
+ "http://clients2.google.com/service/update2/crx";
+const char kValidUpdateUrl2[] =
+ "https://clients2.google.com/service/update2/crx";
+const char kName[] = "MyExtension";
+const char kName2[] = "MyExtension2";
- ExtensionSyncData new_data;
- new_data.id = "id";
- new_data.enabled = false;
- new_data.incognito_enabled = true;
- {
- scoped_ptr<Version> version(Version::GetVersionFromString("1.1.0.0"));
- new_data.version = *version;
- }
- new_data.update_url = GURL("http://www.new.com");
- new_data.name = "new_data";
+class ExtensionSyncDataTest : public testing::Test {
+};
- ExtensionSyncData expected_data = data;
- expected_data.enabled = new_data.enabled;
- expected_data.incognito_enabled = new_data.incognito_enabled;
+TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncData) {
+ sync_pb::EntitySpecifics entity;
+ sync_pb::ExtensionSpecifics* extension_specifics =
+ entity.MutableExtension(sync_pb::extension);
+ extension_specifics->set_id(kValidId);
+ extension_specifics->set_update_url(kValidUpdateUrl2);
+ extension_specifics->set_enabled(false);
+ extension_specifics->set_incognito_enabled(true);
+ extension_specifics->set_version(kVersion1);
+ extension_specifics->set_name(kName);
+ SyncData sync_data =
+ SyncData::CreateLocalData("sync_tag", "non_unique_title", entity);
- data.Merge(new_data);
- EXPECT_TRUE(ExtensionSyncDataEqual(data, expected_data));
+ ExtensionSyncData extension_sync_data(sync_data);
+ EXPECT_EQ(extension_specifics->id(), extension_sync_data.id());
+ EXPECT_EQ(extension_specifics->version(),
+ extension_sync_data.version().GetString());
+ EXPECT_EQ(extension_specifics->update_url(),
+ extension_sync_data.update_url().spec());
+ EXPECT_EQ(extension_specifics->enabled(), extension_sync_data.enabled());
+ EXPECT_EQ(extension_specifics->incognito_enabled(),
+ extension_sync_data.incognito_enabled());
+ EXPECT_EQ(extension_specifics->name(), extension_sync_data.name());
+ EXPECT_FALSE(extension_sync_data.uninstalled());
}
-TEST_F(ExtensionSyncDataTest, MergeNewer) {
- ExtensionSyncData data;
- data.id = "id";
- data.enabled = true;
- data.incognito_enabled = false;
- {
- scoped_ptr<Version> version(Version::GetVersionFromString("1.2.0.0"));
- data.version = *version;
- }
- data.update_url = GURL("http://www.old.com");
- data.name = "data";
-
- ExtensionSyncData new_data;
- new_data.id = "id";
- new_data.enabled = false;
- new_data.incognito_enabled = true;
- {
- scoped_ptr<Version> version(Version::GetVersionFromString("1.3.0.0"));
- new_data.version = *version;
- }
- new_data.update_url = GURL("http://www.new.com");
- new_data.name = "new_data";
+TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncData) {
+ sync_pb::EntitySpecifics entity;
+ sync_pb::ExtensionSpecifics* input_extension =
+ entity.MutableExtension(sync_pb::extension);
+ input_extension->set_id(kValidId);
+ input_extension->set_update_url(kValidUpdateUrl2);
+ input_extension->set_enabled(true);
+ input_extension->set_incognito_enabled(false);
+ input_extension->set_version(kVersion1);
+ input_extension->set_name(kName);
+ SyncData sync_data =
+ SyncData::CreateLocalData("sync_tag", "non_unique_title", entity);
+ ExtensionSyncData extension_sync_data(sync_data);
- data.Merge(new_data);
- EXPECT_TRUE(ExtensionSyncDataEqual(data, new_data));
+ SyncData output_sync_data = extension_sync_data.GetSyncData();
+ const sync_pb::ExtensionSpecifics& output_specifics =
+ output_sync_data.GetSpecifics().GetExtension(sync_pb::extension);
+ EXPECT_EQ(extension_sync_data.id(), output_specifics.id());
+ EXPECT_EQ(extension_sync_data.update_url().spec(),
+ output_specifics.update_url());
+ EXPECT_EQ(extension_sync_data.enabled(), output_specifics.enabled());
+ EXPECT_EQ(extension_sync_data.incognito_enabled(),
+ output_specifics.incognito_enabled());
+ EXPECT_EQ(extension_sync_data.version().GetString(),
+ output_specifics.version());
+ EXPECT_EQ(extension_sync_data.name(), output_specifics.name());
}
} // namespace
« no previous file with comments | « chrome/browser/extensions/extension_sync_data.cc ('k') | chrome/browser/extensions/test_extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698