summaryrefslogtreecommitdiffstats
path: root/base/android/jni_generator/sample_for_tests.h
blob: c98cf97693638963a322c3fd582bb7f541f526b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_
#define BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_

#include <jni.h>
#include <map>
#include <string>

#include "base/android/jni_android.h"
#include "base/basictypes.h"

namespace base {
namespace android {

// This file is used to:
// - document the best practices and guidelines on JNI usage.
// - ensure sample_for_tests_jni.h compiles and the functions declared in it
// as expected.
//
// All methods are called directly from Java. See more documentation in
// SampleForTests.java.
class CPPClass {
 public:
  CPPClass();
  ~CPPClass();

  class InnerClass {
   public:
    jdouble MethodOtherP0(JNIEnv* env, jobject obj);
  };

  void Destroy(JNIEnv* env, jobject obj);

  jint Method(JNIEnv* env, jobject obj);

  void AddStructB(JNIEnv* env, jobject obj, jobject structb);

  void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject obj);

  base::android::ScopedJavaLocalRef<jstring> ReturnAString(
      JNIEnv* env, jobject obj);

 private:
  std::map<long, std::string> map_;

  DISALLOW_COPY_AND_ASSIGN(CPPClass);
};

}  // namespace android
}  // namespace base

#endif  // BASE_ANDROID_JNI_GENERATOR_SAMPLE_FOR_TESTS_H_