JniClassParameterTest.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-04-07
  6. * Changed: 2023-04-10
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std-core-jni-test.hpp>
  11. #include <ls-std/ls-std-core-jni.hpp>
  12. #include <memory>
  13. using ls::std::core::experimental::JniApi;
  14. using ls::std::core::experimental::JniClassParameter;
  15. using ls::std::core::experimental::interface_type::IJniApi;
  16. using std::make_shared;
  17. using std::shared_ptr;
  18. using test::core::jni::MockJniApi;
  19. using testing::Test;
  20. namespace
  21. {
  22. class JniClassParameterTest : public Test
  23. {
  24. public:
  25. JniClassParameterTest() = default;
  26. ~JniClassParameterTest() override = default;
  27. };
  28. TEST_F(JniClassParameterTest, getJavaEnvironment)
  29. {
  30. JniClassParameter parameter{};
  31. ASSERT_TRUE(parameter.getJavaEnvironment() == nullptr);
  32. }
  33. TEST_F(JniClassParameterTest, getJavaObject)
  34. {
  35. JniClassParameter parameter{};
  36. ASSERT_TRUE(parameter.getJavaObject() == nullptr);
  37. }
  38. TEST_F(JniClassParameterTest, getJniApi)
  39. {
  40. JniClassParameter parameter{};
  41. ASSERT_TRUE(parameter.getJniApi() == nullptr);
  42. }
  43. TEST_F(JniClassParameterTest, setJavaEnvironment)
  44. {
  45. JniClassParameter parameter{};
  46. shared_ptr<JNIEnv> environment = make_shared<JNIEnv>();
  47. parameter.setJavaEnvironment(environment.get());
  48. ASSERT_TRUE(parameter.getJavaEnvironment() == environment.get());
  49. }
  50. TEST_F(JniClassParameterTest, setJavaObject)
  51. {
  52. JniClassParameter parameter{};
  53. shared_ptr<_jobject> javaObject = make_shared<_jobject>();
  54. parameter.setJavaObject(javaObject.get());
  55. ASSERT_TRUE(parameter.getJavaObject() == javaObject.get());
  56. }
  57. TEST_F(JniClassParameterTest, setJniApi)
  58. {
  59. JniClassParameter parameter{};
  60. shared_ptr<IJniApi> jniApi = make_shared<MockJniApi>();
  61. parameter.setJniApi(jniApi);
  62. ASSERT_TRUE(parameter.getJniApi() == jniApi);
  63. }
  64. }