This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[flutter_plugin_tools] Add Linux support to native-test #4294
Merged
stuartmorgan-g
merged 11 commits into
flutter:master
from
stuartmorgan-g:linux-unit-test
Sep 1, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
523f9cf
Add a simple unit test to url_launcher_linux
stuartmorgan-g 4107c6e
Add Linux support to native-test
stuartmorgan-g 9f1f56e
Enable in CI
stuartmorgan-g 3616b24
Remove CMake cruft
stuartmorgan-g e223710
Merge branch 'master' into linux-unit-test
stuartmorgan-g d5391c4
Format fix
stuartmorgan-g b6b1cd7
Unit test only to avoid warning
stuartmorgan-g 6bead5b
Add doctor call temporarily for debugging
stuartmorgan-g 9c290d6
Revert "Add doctor call temporarily for debugging"
stuartmorgan-g 597f04f
Switch to release for GoogleTest tests
stuartmorgan-g 4dc5490
comment as TODO
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/url_launcher/url_launcher_linux/linux/test/url_launcher_linux_test.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
#include <flutter_linux/flutter_linux.h> | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "include/url_launcher_linux/url_launcher_plugin.h" | ||
#include "url_launcher_plugin_private.h" | ||
|
||
namespace url_launcher_plugin { | ||
namespace test { | ||
|
||
TEST(UrlLauncherPlugin, CanLaunchSuccess) { | ||
g_autoptr(FlValue) args = fl_value_new_map(); | ||
fl_value_set_string_take(args, "url", | ||
fl_value_new_string("https://flutter.dev")); | ||
FlMethodResponse* response = can_launch(nullptr, args); | ||
ASSERT_NE(response, nullptr); | ||
ASSERT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response)); | ||
g_autoptr(FlValue) expected = fl_value_new_bool(true); | ||
EXPECT_TRUE(fl_value_equal(fl_method_success_response_get_result( | ||
FL_METHOD_SUCCESS_RESPONSE(response)), | ||
expected)); | ||
} | ||
|
||
TEST(UrlLauncherPlugin, CanLaunchFailureUnhandled) { | ||
g_autoptr(FlValue) args = fl_value_new_map(); | ||
fl_value_set_string_take(args, "url", fl_value_new_string("madeup:scheme")); | ||
FlMethodResponse* response = can_launch(nullptr, args); | ||
ASSERT_NE(response, nullptr); | ||
ASSERT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response)); | ||
g_autoptr(FlValue) expected = fl_value_new_bool(false); | ||
EXPECT_TRUE(fl_value_equal(fl_method_success_response_get_result( | ||
FL_METHOD_SUCCESS_RESPONSE(response)), | ||
expected)); | ||
} | ||
|
||
// For consistency with the established mobile implementations, | ||
// an invalid URL should return false, not an error. | ||
TEST(UrlLauncherPlugin, CanLaunchFailureInvalidUrl) { | ||
g_autoptr(FlValue) args = fl_value_new_map(); | ||
fl_value_set_string_take(args, "url", fl_value_new_string("")); | ||
FlMethodResponse* response = can_launch(nullptr, args); | ||
ASSERT_NE(response, nullptr); | ||
ASSERT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response)); | ||
g_autoptr(FlValue) expected = fl_value_new_bool(false); | ||
EXPECT_TRUE(fl_value_equal(fl_method_success_response_get_result( | ||
FL_METHOD_SUCCESS_RESPONSE(response)), | ||
expected)); | ||
} | ||
|
||
} // namespace test | ||
} // namespace url_launcher_plugin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/url_launcher/url_launcher_linux/linux/url_launcher_plugin_private.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <flutter_linux/flutter_linux.h> | ||
|
||
#include "include/url_launcher_linux/url_launcher_plugin.h" | ||
|
||
// TODO(stuartmorgan): Remove this private header and change the below back to | ||
// a static function once https://github.com/flutter/flutter/issues/88724 | ||
// is fixed, and test through the public API instead. | ||
|
||
// Handles the canLaunch method call. | ||
FlMethodResponse* can_launch(FlUrlLauncherPlugin* self, FlValue* args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was going to say perhaps we should be changing to generate a debug build of build-examples given that it's typically more convenient to debug debug builds. That said, in the end you want to verify the release build of the library code in the plugin, and people shouldn't be relying on
#ifdef
'ed code in their tests, so this seems fine.If this ever gets problematic, we could add a buildmode flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that there's actually a more annoying problem, which is that the current behavior isn't going to be good for local use. Filed flutter/flutter#89303.
I'm going to do that as a follow-up since it applies to the already-landed Windows flow in the same way, but I'll do it shortly.