diff options
author | pvalenzuela <pvalenzuela@chromium.org> | 2015-02-06 11:43:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-06 19:44:29 +0000 |
commit | 2d2ac36ec2f96b234961e30e396f7d31a08207ce (patch) | |
tree | ab46509fa4b4f8ba57eb4755c01bcb31746faf06 /sync | |
parent | c65111da7946762cc92e247d835c5d1a8c2ae668 (diff) | |
download | chromium_src-2d2ac36ec2f96b234961e30e396f7d31a08207ce.zip chromium_src-2d2ac36ec2f96b234961e30e396f7d31a08207ce.tar.gz chromium_src-2d2ac36ec2f96b234961e30e396f7d31a08207ce.tar.bz2 |
Create a Android Sync integration test for typed URLs
This is a re-land of https://codereview.chromium.org/862113005/
This CL introduces JNI plumbing for one method of the FakeServer's
verification API. One test (testUploadTypedUrl) has been added to use
the API; it types a URL on the client and verifies that the URL was
sent to the server.
BUG=NONE
Review URL: https://codereview.chromium.org/884073005
Cr-Commit-Position: refs/heads/master@{#315088}
Diffstat (limited to 'sync')
-rw-r--r-- | sync/BUILD.gn | 1 | ||||
-rw-r--r-- | sync/sync_tests.gypi | 4 | ||||
-rw-r--r-- | sync/test/fake_server/android/fake_server_helper_android.cc | 32 | ||||
-rw-r--r-- | sync/test/fake_server/android/fake_server_helper_android.h | 9 |
4 files changed, 46 insertions, 0 deletions
diff --git a/sync/BUILD.gn b/sync/BUILD.gn index df5f23a..605f797 100644 --- a/sync/BUILD.gn +++ b/sync/BUILD.gn @@ -804,6 +804,7 @@ if (is_android) { ":fake_server_jni", ":test_support_sync_fake_server", "//base", + "//testing/gtest", ] } } diff --git a/sync/sync_tests.gypi b/sync/sync_tests.gypi index b1ef9cf..bf41fc3 100644 --- a/sync/sync_tests.gypi +++ b/sync/sync_tests.gypi @@ -475,8 +475,12 @@ 'dependencies': [ 'sync_fake_server_jni_headers', 'test_support_sync_fake_server', + '../testing/gtest.gyp:gtest', '../base/base.gyp:base', ], + 'export_dependent_settings': [ + '../testing/gtest.gyp:gtest', + ], 'sources': [ 'test/fake_server/android/fake_server_helper_android.cc', 'test/fake_server/android/fake_server_helper_android.h', diff --git a/sync/test/fake_server/android/fake_server_helper_android.cc b/sync/test/fake_server/android/fake_server_helper_android.cc index 725ba63..8491474 100644 --- a/sync/test/fake_server/android/fake_server_helper_android.cc +++ b/sync/test/fake_server/android/fake_server_helper_android.cc @@ -6,11 +6,17 @@ #include <jni.h> +#include "base/android/jni_string.h" #include "base/basictypes.h" +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "jni/FakeServerHelper_jni.h" +#include "sync/internal_api/public/base/model_type.h" #include "sync/internal_api/public/network_resources.h" #include "sync/test/fake_server/fake_server.h" #include "sync/test/fake_server/fake_server_network_resources.h" +#include "sync/test/fake_server/fake_server_verifier.h" +#include "testing/gtest/include/gtest/gtest.h" FakeServerHelperAndroid::FakeServerHelperAndroid(JNIEnv* env, jobject obj) { } @@ -46,6 +52,32 @@ void FakeServerHelperAndroid::DeleteFakeServer(JNIEnv* env, delete fake_server_ptr; } +jboolean FakeServerHelperAndroid::VerifyEntityCountByTypeAndName( + JNIEnv* env, + jobject obj, + jlong fake_server, + jlong count, + jstring model_type_string, + jstring name) { + syncer::ModelType model_type; + if (!NotificationTypeToRealModelType(base::android::ConvertJavaStringToUTF8( + env, model_type_string), &model_type)) { + LOG(WARNING) << "Invalid ModelType string."; + return false; + } + fake_server::FakeServer* fake_server_ptr = + reinterpret_cast<fake_server::FakeServer*>(fake_server); + fake_server::FakeServerVerifier fake_server_verifier(fake_server_ptr); + testing::AssertionResult result = + fake_server_verifier.VerifyEntityCountByTypeAndName( + count, model_type, base::android::ConvertJavaStringToUTF8(env, name)); + + if (!result) + LOG(WARNING) << result.message(); + + return result; +} + // static bool FakeServerHelperAndroid::Register(JNIEnv* env) { return RegisterNativesImpl(env); diff --git a/sync/test/fake_server/android/fake_server_helper_android.h b/sync/test/fake_server/android/fake_server_helper_android.h index 24e1d9e..dfbdb7b 100644 --- a/sync/test/fake_server/android/fake_server_helper_android.h +++ b/sync/test/fake_server/android/fake_server_helper_android.h @@ -30,6 +30,15 @@ class FakeServerHelperAndroid { // CreateFakeServer). void DeleteFakeServer(JNIEnv* env, jobject obj, jlong fake_server); + // Returns true if and only if |fake_server| contains |count| entities that + // match |model_type_string| and |name|. + jboolean VerifyEntityCountByTypeAndName(JNIEnv* env, + jobject obj, + jlong fake_server, + jlong count, + jstring model_type_string, + jstring name); + private: virtual ~FakeServerHelperAndroid(); }; |