JniClassParameterTest.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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-07
  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::JniApi;
  14. using ls::std::core::JniClassParameter;
  15. using ls::std::core::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, getJniApi)
  34. {
  35. JniClassParameter parameter{};
  36. ASSERT_TRUE(parameter.getJniApi() == nullptr);
  37. }
  38. TEST_F(JniClassParameterTest, setJniApi)
  39. {
  40. JniClassParameter parameter{};
  41. shared_ptr<IJniApi> jniApi = make_shared<MockJniApi>();
  42. parameter.setJniApi(jniApi);
  43. ASSERT_TRUE(parameter.getJniApi() == jniApi);
  44. }
  45. TEST_F(JniClassParameterTest, setJavaEnvironment)
  46. {
  47. JniClassParameter parameter{};
  48. shared_ptr<JNIEnv> environment = make_shared<JNIEnv>();
  49. parameter.setJavaEnvironment(environment.get());
  50. ASSERT_TRUE(parameter.getJavaEnvironment() == environment.get());
  51. }
  52. }