first pass Windows implementation
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#ifndef FLUTTER_PLUGIN_POLYVOX_FILAMENT_PLUGIN_C_API_H_
|
||||
#define FLUTTER_PLUGIN_POLYVOX_FILAMENT_PLUGIN_C_API_H_
|
||||
|
||||
#include <flutter_plugin_registrar.h>
|
||||
|
||||
#ifdef FLUTTER_PLUGIN_IMPL
|
||||
#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void PolyvoxFilamentPluginCApiRegisterWithRegistrar(
|
||||
FlutterDesktopPluginRegistrarRef registrar);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // FLUTTER_PLUGIN_POLYVOX_FILAMENT_PLUGIN_C_API_H_
|
||||
31
windows/polyvox_filament_plugin.h
Normal file
31
windows/polyvox_filament_plugin.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef FLUTTER_PLUGIN_POLYVOX_FILAMENT_PLUGIN_H_
|
||||
#define FLUTTER_PLUGIN_POLYVOX_FILAMENT_PLUGIN_H_
|
||||
|
||||
#include <flutter/method_channel.h>
|
||||
#include <flutter/plugin_registrar_windows.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace polyvox_filament {
|
||||
|
||||
class PolyvoxFilamentPlugin : public flutter::Plugin {
|
||||
public:
|
||||
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
|
||||
|
||||
PolyvoxFilamentPlugin();
|
||||
|
||||
virtual ~PolyvoxFilamentPlugin();
|
||||
|
||||
// Disallow copy and assign.
|
||||
PolyvoxFilamentPlugin(const PolyvoxFilamentPlugin&) = delete;
|
||||
PolyvoxFilamentPlugin& operator=(const PolyvoxFilamentPlugin&) = delete;
|
||||
|
||||
// Called when a method is called on this plugin's channel from Dart.
|
||||
void HandleMethodCall(
|
||||
const flutter::MethodCall<flutter::EncodableValue> &method_call,
|
||||
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||
};
|
||||
|
||||
} // namespace polyvox_filament
|
||||
|
||||
#endif // FLUTTER_PLUGIN_POLYVOX_FILAMENT_PLUGIN_H_
|
||||
12
windows/polyvox_filament_plugin_c_api.cpp
Normal file
12
windows/polyvox_filament_plugin_c_api.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "include/polyvox_filament/polyvox_filament_plugin_c_api.h"
|
||||
|
||||
#include <flutter/plugin_registrar_windows.h>
|
||||
|
||||
#include "polyvox_filament_plugin.h"
|
||||
|
||||
void PolyvoxFilamentPluginCApiRegisterWithRegistrar(
|
||||
FlutterDesktopPluginRegistrarRef registrar) {
|
||||
polyvox_filament::PolyvoxFilamentPlugin::RegisterWithRegistrar(
|
||||
flutter::PluginRegistrarManager::GetInstance()
|
||||
->GetRegistrar<flutter::PluginRegistrarWindows>(registrar));
|
||||
}
|
||||
43
windows/test/polyvox_filament_plugin_test.cpp
Normal file
43
windows/test/polyvox_filament_plugin_test.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <flutter/method_call.h>
|
||||
#include <flutter/method_result_functions.h>
|
||||
#include <flutter/standard_method_codec.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include "polyvox_filament_plugin.h"
|
||||
|
||||
namespace polyvox_filament {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
|
||||
using flutter::EncodableMap;
|
||||
using flutter::EncodableValue;
|
||||
using flutter::MethodCall;
|
||||
using flutter::MethodResultFunctions;
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(PolyvoxFilamentPlugin, GetPlatformVersion) {
|
||||
PolyvoxFilamentPlugin plugin;
|
||||
// Save the reply value from the success callback.
|
||||
std::string result_string;
|
||||
plugin.HandleMethodCall(
|
||||
MethodCall("getPlatformVersion", std::make_unique<EncodableValue>()),
|
||||
std::make_unique<MethodResultFunctions<>>(
|
||||
[&result_string](const EncodableValue* result) {
|
||||
result_string = std::get<std::string>(*result);
|
||||
},
|
||||
nullptr, nullptr));
|
||||
|
||||
// Since the exact string varies by host, just ensure that it's a string
|
||||
// with the expected format.
|
||||
EXPECT_TRUE(result_string.rfind("Windows ", 0) == 0);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace polyvox_filament
|
||||
Reference in New Issue
Block a user