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
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
{
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
25 jlong
CreateFakeServer(JNIEnv
* env
, jobject obj
);
27 // Factory method for creating a native NetworkResources object. The caller
29 jlong
CreateNetworkResources(JNIEnv
* env
, jobject obj
, jlong fake_server
);
31 // Deletes the given |fake_server| (a FakeServer pointer created via
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
,
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
,
49 jobjectArray url_array
);
51 // Return the entities for |model_type_string| on |fake_server|.
52 base::android::ScopedJavaLocalRef
<jobjectArray
> GetSyncEntitiesByModelType(
58 // Injects a UniqueClientEntity into |fake_server|.
59 void InjectUniqueClientEntity(JNIEnv
* env
,
63 jbyteArray serialized_entity_specifics
);
65 // Modifies the entity with |id| on |fake_server|.
66 void ModifyEntitySpecifics(JNIEnv
* env
,
70 jbyteArray serialized_entity_specifics
);
72 // Injects a BookmarkEntity into |fake_server|.
73 void InjectBookmarkEntity(JNIEnv
* env
,
80 // Injects a bookmark folder entity into |fake_server|.
81 void InjectBookmarkFolderEntity(JNIEnv
* env
,
87 // Modify the BookmarkEntity with |entity_id| on |fake_server|.
88 void ModifyBookmarkEntity(JNIEnv
* env
,
96 // Modify the bookmark folder with |entity_id| on |fake_server|.
97 void ModifyBookmarkFolderEntity(JNIEnv
* env
,
104 // Returns the bookmark bar folder ID.
105 base::android::ScopedJavaLocalRef
<jstring
> GetBookmarkBarFolderId(
110 // Deletes an entity on the server. This is the JNI way of injecting a
112 void DeleteEntity(JNIEnv
* env
,
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(
133 #endif // SYNC_TEST_FAKE_SERVER_ANDROID_FAKE_SERVER_HELPER_ANDROID