Flutter Engine
The Flutter Engine
Functions
fl_method_response_test.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_response.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (FlMethodResponseTest, Success)
 
 TEST (FlMethodResponseTest, Error)
 
 TEST (FlMethodResponseTest, ErrorMessage)
 
 TEST (FlMethodResponseTest, ErrorDetails)
 
 TEST (FlMethodResponseTest, ErrorMessageAndDetails)
 
 TEST (FlMethodResponseTest, NotImplemented)
 
 TEST (FlMethodResponseTest, SuccessGetResult)
 
 TEST (FlMethodResponseTest, ErrorGetResult)
 
 TEST (FlMethodResponseTest, NotImplementedGetResult)
 

Function Documentation

◆ TEST() [1/9]

TEST ( FlMethodResponseTest  ,
Error   
)

Definition at line 17 of file fl_method_response_test.cc.

17 {
18 g_autoptr(FlMethodErrorResponse) response =
19 fl_method_error_response_new("code", nullptr, nullptr);
20 EXPECT_STREQ(fl_method_error_response_get_code(response), "code");
21 EXPECT_EQ(fl_method_error_response_get_message(response), nullptr);
22 EXPECT_EQ(fl_method_error_response_get_details(response), nullptr);
23}
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
G_MODULE_EXPORT FlValue * fl_method_error_response_get_details(FlMethodErrorResponse *self)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)

◆ TEST() [2/9]

TEST ( FlMethodResponseTest  ,
ErrorDetails   
)

Definition at line 33 of file fl_method_response_test.cc.

33 {
34 g_autoptr(FlValue) details = fl_value_new_int(42);
35 g_autoptr(FlMethodErrorResponse) response =
36 fl_method_error_response_new("code", nullptr, details);
37 EXPECT_STREQ(fl_method_error_response_get_code(response), "code");
38 EXPECT_EQ(fl_method_error_response_get_message(response), nullptr);
39 g_autoptr(FlValue) expected_details = fl_value_new_int(42);
41 expected_details));
42}
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition: fl_value.cc:471
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678

◆ TEST() [3/9]

TEST ( FlMethodResponseTest  ,
ErrorGetResult   
)

Definition at line 76 of file fl_method_response_test.cc.

76 {
77 g_autoptr(FlMethodErrorResponse) response =
78 fl_method_error_response_new("code", nullptr, nullptr);
79 g_autoptr(GError) error = nullptr;
80 g_autoptr(FlValue) result =
81 fl_method_response_get_result(FL_METHOD_RESPONSE(response), &error);
82 EXPECT_EQ(result, nullptr);
85}
G_MODULE_EXPORT FlValue * fl_method_response_get_result(FlMethodResponse *self, GError **error)
@ FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR
#define FL_METHOD_RESPONSE_ERROR
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result

◆ TEST() [4/9]

TEST ( FlMethodResponseTest  ,
ErrorMessage   
)

Definition at line 25 of file fl_method_response_test.cc.

25 {
26 g_autoptr(FlMethodErrorResponse) response =
27 fl_method_error_response_new("code", "message", nullptr);
28 EXPECT_STREQ(fl_method_error_response_get_code(response), "code");
29 EXPECT_STREQ(fl_method_error_response_get_message(response), "message");
30 EXPECT_EQ(fl_method_error_response_get_details(response), nullptr);
31}

◆ TEST() [5/9]

TEST ( FlMethodResponseTest  ,
ErrorMessageAndDetails   
)

Definition at line 44 of file fl_method_response_test.cc.

44 {
45 g_autoptr(FlValue) details = fl_value_new_int(42);
46 g_autoptr(FlMethodErrorResponse) response =
47 fl_method_error_response_new("code", "message", details);
48 EXPECT_STREQ(fl_method_error_response_get_code(response), "code");
49 EXPECT_STREQ(fl_method_error_response_get_message(response), "message");
50 g_autoptr(FlValue) expected_details = fl_value_new_int(42);
52 expected_details));
53}

◆ TEST() [6/9]

TEST ( FlMethodResponseTest  ,
NotImplemented   
)

Definition at line 55 of file fl_method_response_test.cc.

55 {
56 g_autoptr(FlMethodNotImplementedResponse) response =
58 // Trivial check to stop the compiler deciding that 'response' is an unused
59 // variable.
60 EXPECT_TRUE(FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response));
61}
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()

◆ TEST() [7/9]

TEST ( FlMethodResponseTest  ,
NotImplementedGetResult   
)

Definition at line 87 of file fl_method_response_test.cc.

87 {
88 g_autoptr(FlMethodNotImplementedResponse) response =
90 g_autoptr(GError) error = nullptr;
91 g_autoptr(FlValue) result =
92 fl_method_response_get_result(FL_METHOD_RESPONSE(response), &error);
93 EXPECT_EQ(result, nullptr);
96}
@ FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED

◆ TEST() [8/9]

TEST ( FlMethodResponseTest  ,
Success   
)

Definition at line 8 of file fl_method_response_test.cc.

8 {
9 g_autoptr(FlValue) result = fl_value_new_int(42);
10 g_autoptr(FlMethodSuccessResponse) response =
12 g_autoptr(FlValue) expected = fl_value_new_int(42);
14 expected));
15}
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)

◆ TEST() [9/9]

TEST ( FlMethodResponseTest  ,
SuccessGetResult   
)

Definition at line 63 of file fl_method_response_test.cc.

63 {
64 g_autoptr(FlValue) r = fl_value_new_int(42);
65 g_autoptr(FlMethodSuccessResponse) response =
67 g_autoptr(GError) error = nullptr;
69 fl_method_response_get_result(FL_METHOD_RESPONSE(response), &error);
70 ASSERT_NE(result, nullptr);
71 EXPECT_EQ(error, nullptr);
72 g_autoptr(FlValue) expected = fl_value_new_int(42);
73 ASSERT_TRUE(fl_value_equal(result, expected));
74}