| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/android/java/jni_helper.h" | 5 #include "content/browser/android/java/jni_helper.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 g_last_jni_signature = jni_signature; | 31 g_last_jni_signature = jni_signature; |
| 32 g_last_method_id = g_previous_functions->GetMethodID(env, clazz, method, | 32 g_last_method_id = g_previous_functions->GetMethodID(env, clazz, method, |
| 33 jni_signature); | 33 jni_signature); |
| 34 return g_last_method_id; | 34 return g_last_method_id; |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 class JNIAndroidTest : public testing::Test { | 39 class JNIAndroidTest : public testing::Test { |
| 40 protected: | 40 protected: |
| 41 virtual void SetUp() { | 41 void SetUp() override { |
| 42 JNIEnv* env = base::android::AttachCurrentThread(); | 42 JNIEnv* env = base::android::AttachCurrentThread(); |
| 43 g_previous_functions = env->functions; | 43 g_previous_functions = env->functions; |
| 44 hooked_functions = *g_previous_functions; | 44 hooked_functions = *g_previous_functions; |
| 45 env->functions = &hooked_functions; | 45 env->functions = &hooked_functions; |
| 46 hooked_functions.GetMethodID = &GetMethodIDWrapper; | 46 hooked_functions.GetMethodID = &GetMethodIDWrapper; |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void TearDown() { | 49 void TearDown() override { |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 50 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 env->functions = g_previous_functions; | 51 env->functions = g_previous_functions; |
| 52 Reset(); | 52 Reset(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void Reset() { | 55 void Reset() { |
| 56 g_last_method = 0; | 56 g_last_method = 0; |
| 57 g_last_jni_signature = 0; | 57 g_last_jni_signature = 0; |
| 58 g_last_method_id = NULL; | 58 g_last_method_id = NULL; |
| 59 } | 59 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 | 85 |
| 86 Reset(); | 86 Reset(); |
| 87 jmethodID id3 = GetMethodIDFromClassName(env, kJavaLangObject, kToString, | 87 jmethodID id3 = GetMethodIDFromClassName(env, kJavaLangObject, kToString, |
| 88 kReturningJavaLangString); | 88 kReturningJavaLangString); |
| 89 EXPECT_STREQ(kToString, g_last_method); | 89 EXPECT_STREQ(kToString, g_last_method); |
| 90 EXPECT_STREQ(kReturningJavaLangString, g_last_jni_signature); | 90 EXPECT_STREQ(kReturningJavaLangString, g_last_jni_signature); |
| 91 EXPECT_EQ(g_last_method_id, id3); | 91 EXPECT_EQ(g_last_method_id, id3); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace content | 94 } // namespace content |
| OLD | NEW |