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

Side by Side Diff: base/android/scoped_java_ref_unittest.cc

Issue 900613004: Update {virtual,override,final} to follow C++11 style in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/android/trace_event_binding.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/android/scoped_java_ref.h" 5 #include "base/android/scoped_java_ref.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 void DeleteLocalRef(JNIEnv* env, jobject obj) { 35 void DeleteLocalRef(JNIEnv* env, jobject obj) {
36 --g_local_refs; 36 --g_local_refs;
37 return g_previous_functions->DeleteLocalRef(env, obj); 37 return g_previous_functions->DeleteLocalRef(env, obj);
38 } 38 }
39 } // namespace 39 } // namespace
40 40
41 class ScopedJavaRefTest : public testing::Test { 41 class ScopedJavaRefTest : public testing::Test {
42 protected: 42 protected:
43 virtual void SetUp() { 43 void SetUp() override {
44 g_local_refs = 0; 44 g_local_refs = 0;
45 g_global_refs = 0; 45 g_global_refs = 0;
46 JNIEnv* env = AttachCurrentThread(); 46 JNIEnv* env = AttachCurrentThread();
47 g_previous_functions = env->functions; 47 g_previous_functions = env->functions;
48 hooked_functions = *g_previous_functions; 48 hooked_functions = *g_previous_functions;
49 env->functions = &hooked_functions; 49 env->functions = &hooked_functions;
50 // We inject our own functions in JNINativeInterface so we can keep track 50 // We inject our own functions in JNINativeInterface so we can keep track
51 // of the reference counting ourselves. 51 // of the reference counting ourselves.
52 hooked_functions.NewGlobalRef = &NewGlobalRef; 52 hooked_functions.NewGlobalRef = &NewGlobalRef;
53 hooked_functions.DeleteGlobalRef = &DeleteGlobalRef; 53 hooked_functions.DeleteGlobalRef = &DeleteGlobalRef;
54 hooked_functions.NewLocalRef = &NewLocalRef; 54 hooked_functions.NewLocalRef = &NewLocalRef;
55 hooked_functions.DeleteLocalRef = &DeleteLocalRef; 55 hooked_functions.DeleteLocalRef = &DeleteLocalRef;
56 } 56 }
57 57
58 virtual void TearDown() { 58 void TearDown() override {
59 JNIEnv* env = AttachCurrentThread(); 59 JNIEnv* env = AttachCurrentThread();
60 env->functions = g_previous_functions; 60 env->functions = g_previous_functions;
61 } 61 }
62 // From JellyBean release, the instance of this struct provided in JNIEnv is 62 // From JellyBean release, the instance of this struct provided in JNIEnv is
63 // read-only, so we deep copy it to allow individual functions to be hooked. 63 // read-only, so we deep copy it to allow individual functions to be hooked.
64 JNINativeInterface hooked_functions; 64 JNINativeInterface hooked_functions;
65 }; 65 };
66 66
67 // The main purpose of this is testing the various conversions compile. 67 // The main purpose of this is testing the various conversions compile.
68 TEST_F(ScopedJavaRefTest, Conversions) { 68 TEST_F(ScopedJavaRefTest, Conversions) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ScopedJavaGlobalRef<jobject> global_obj2(global_obj); 113 ScopedJavaGlobalRef<jobject> global_obj2(global_obj);
114 EXPECT_EQ(2, g_global_refs); 114 EXPECT_EQ(2, g_global_refs);
115 } 115 }
116 116
117 EXPECT_EQ(0, g_local_refs); 117 EXPECT_EQ(0, g_local_refs);
118 EXPECT_EQ(0, g_global_refs); 118 EXPECT_EQ(0, g_global_refs);
119 } 119 }
120 120
121 } // namespace android 121 } // namespace android
122 } // namespace base 122 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/android/trace_event_binding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698