Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / sync / test / fake_server / android / fake_server_helper_android.h
bloba0418ed730d75ab19d0ed1bcaf4b6034f06bcb00
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SYNC_TEST_FAKE_SERVER_ANDROID_FAKE_SERVER_HELPER_ANDROID
6 #define SYNC_TEST_FAKE_SERVER_ANDROID_FAKE_SERVER_HELPER_ANDROID
8 #include <jni.h>
10 #include "base/android/scoped_java_ref.h"
11 #include "base/basictypes.h"
12 #include "sync/test/fake_server/entity_builder_factory.h"
14 // Helper for utilizing native FakeServer infrastructure in Android tests.
15 class FakeServerHelperAndroid {
16 public:
17 // Registers the native methods.
18 static bool Register(JNIEnv* env);
20 // Creates a FakeServerHelperAndroid.
21 FakeServerHelperAndroid(JNIEnv* env, jobject obj);
23 // Factory method for creating a native FakeServer object. The caller assumes
24 // ownership.
25 jlong CreateFakeServer(JNIEnv* env, jobject obj);
27 // Factory method for creating a native NetworkResources object. The caller
28 // assumes ownership.
29 jlong CreateNetworkResources(JNIEnv* env, jobject obj, jlong fake_server);
31 // Deletes the given |fake_server| (a FakeServer pointer created via
32 // CreateFakeServer).
33 void DeleteFakeServer(JNIEnv* env, jobject obj, jlong fake_server);
35 // Returns true if and only if |fake_server| contains |count| entities that
36 // match |model_type_string| and |name|.
37 jboolean VerifyEntityCountByTypeAndName(JNIEnv* env,
38 jobject obj,
39 jlong fake_server,
40 jlong count,
41 jint model_type_int,
42 jstring name);
44 // Returns true iff |fake_server| has exactly one window of sessions with
45 // tabs matching |url_array|. The order of the array does not matter.
46 jboolean VerifySessions(JNIEnv* env,
47 jobject obj,
48 jlong fake_server,
49 jobjectArray url_array);
51 // Return the entities for |model_type_string| on |fake_server|.
52 base::android::ScopedJavaLocalRef<jobjectArray> GetSyncEntitiesByModelType(
53 JNIEnv* env,
54 jobject obj,
55 jlong fake_server,
56 jint model_type_int);
58 // Injects a UniqueClientEntity into |fake_server|.
59 void InjectUniqueClientEntity(JNIEnv* env,
60 jobject obj,
61 jlong fake_server,
62 jstring name,
63 jbyteArray serialized_entity_specifics);
65 // Modifies the entity with |id| on |fake_server|.
66 void ModifyEntitySpecifics(JNIEnv* env,
67 jobject obj,
68 jlong fake_server,
69 jstring name,
70 jbyteArray serialized_entity_specifics);
72 // Injects a BookmarkEntity into |fake_server|.
73 void InjectBookmarkEntity(JNIEnv* env,
74 jobject obj,
75 jlong fake_server,
76 jstring title,
77 jstring url,
78 jstring parent_id);
80 // Injects a bookmark folder entity into |fake_server|.
81 void InjectBookmarkFolderEntity(JNIEnv* env,
82 jobject obj,
83 jlong fake_server,
84 jstring title,
85 jstring parent_id);
87 // Modify the BookmarkEntity with |entity_id| on |fake_server|.
88 void ModifyBookmarkEntity(JNIEnv* env,
89 jobject obj,
90 jlong fake_server,
91 jstring entity_id,
92 jstring title,
93 jstring url,
94 jstring parent_id);
96 // Modify the bookmark folder with |entity_id| on |fake_server|.
97 void ModifyBookmarkFolderEntity(JNIEnv* env,
98 jobject obj,
99 jlong fake_server,
100 jstring entity_id,
101 jstring title,
102 jstring parent_id);
104 // Returns the bookmark bar folder ID.
105 base::android::ScopedJavaLocalRef<jstring> GetBookmarkBarFolderId(
106 JNIEnv* env,
107 jobject obj,
108 jlong fake_server);
110 // Deletes an entity on the server. This is the JNI way of injecting a
111 // tombstone.
112 void DeleteEntity(JNIEnv* env,
113 jobject obj,
114 jlong fake_server,
115 jstring id);
117 private:
118 virtual ~FakeServerHelperAndroid();
120 // Deserializes |serialized_entity_specifics| into |entity_specifics|.
121 void DeserializeEntitySpecifics(JNIEnv* env,
122 jbyteArray serialized_entity_specifics,
123 sync_pb::EntitySpecifics& entity_specifics);
125 // Creates a bookmark entity.
126 scoped_ptr<fake_server::FakeServerEntity> CreateBookmarkEntity(
127 JNIEnv* env,
128 jstring title,
129 jstring url,
130 jstring parent_id);
133 #endif // SYNC_TEST_FAKE_SERVER_ANDROID_FAKE_SERVER_HELPER_ANDROID