-
Notifications
You must be signed in to change notification settings - Fork 9
Send view focus events and handle focus change requests #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
118 changes: 118 additions & 0 deletions
118
flutter/shell/platform/tizen/flutter_tizen_view_unittests.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,118 @@ | ||
| // Copyright 2026 Samsung Electronics Co., Ltd. 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/shell/platform/tizen/flutter_tizen_view.h" | ||
|
|
||
| #include <Ecore.h> | ||
|
|
||
| #include <vector> | ||
|
|
||
| #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h" | ||
| #include "flutter/shell/platform/tizen/testing/engine_modifier.h" | ||
| #include "flutter/shell/platform/tizen/tizen_window.h" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace flutter { | ||
| namespace testing { | ||
| namespace { | ||
|
|
||
| class TestTizenView : public TizenWindow { | ||
| public: | ||
| TestTizenView() : TizenWindow({}, false, true, false) { | ||
| input_method_context_ = std::make_unique<TizenInputMethodContext>(0); | ||
| } | ||
|
|
||
| void* GetRenderTarget() override { return nullptr; } | ||
| void* GetNativeHandle() override { return nullptr; } | ||
| uintptr_t GetWindowId() override { return 0; } | ||
| TizenGeometry GetGeometry() override { return {0, 0, 100, 100}; } | ||
| bool SetGeometry(TizenGeometry geometry) override { return true; } | ||
| int32_t GetDpi() override { return 160; } | ||
| uint32_t GetResourceId() override { return 0; } | ||
| void UpdateFlutterCursor(const std::string& kind) override {} | ||
| void Show() override {} | ||
| int32_t GetRotation() override { return 0; } | ||
| void SetPreferredOrientations(const std::vector<int>& rotations) override {} | ||
| void* GetRenderTargetDisplay() override { return nullptr; } | ||
| TizenGeometry GetScreenGeometry() override { return GetGeometry(); } | ||
| void BindKeys(const std::vector<std::string>& keys) override {} | ||
| void ActivateWindow() override { activated = true; } | ||
| void RaiseWindow() override {} | ||
| void LowerWindow() override {} | ||
|
|
||
| void SetFocusable(bool focusable) { focusable_ = focusable; } | ||
|
|
||
| bool activated = false; | ||
| }; | ||
|
|
||
| TEST(FlutterTizenViewTest, SendsAndRequestsViewFocus) { | ||
| ecore_init(); | ||
| { | ||
| FlutterDesktopEngineProperties properties = {}; | ||
| properties.assets_path = "/foo/flutter_assets"; | ||
| properties.icu_data_path = "/foo/icudtl.dat"; | ||
| properties.aot_library_path = "/foo/libapp.so"; | ||
|
|
||
| FlutterProjectBundle project(properties); | ||
| auto engine = std::make_unique<FlutterTizenEngine>(project); | ||
| std::vector<FlutterViewFocusEvent> sent_events; | ||
| EngineModifier modifier(engine.get()); | ||
| modifier.SetEngine(reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1)); | ||
| modifier.embedder_api().SendViewFocusEvent = MOCK_ENGINE_PROC( | ||
| SendViewFocusEvent, | ||
| ([&sent_events](auto engine, const FlutterViewFocusEvent* event) { | ||
| sent_events.push_back(*event); | ||
| return kSuccess; | ||
| })); | ||
| modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; }; | ||
|
|
||
| auto tizen_view = std::make_unique<TestTizenView>(); | ||
| TestTizenView* tizen_view_ptr = tizen_view.get(); | ||
| FlutterTizenView view(kImplicitViewId, std::move(tizen_view), | ||
| std::move(engine), kEVulkan); | ||
|
|
||
| view.OnFocus(kFocused); | ||
| view.OnFocus(kFocused); | ||
| ASSERT_EQ(sent_events.size(), 1u); | ||
| EXPECT_EQ(sent_events[0].struct_size, sizeof(FlutterViewFocusEvent)); | ||
| EXPECT_EQ(sent_events[0].view_id, kImplicitViewId); | ||
| EXPECT_EQ(sent_events[0].state, kFocused); | ||
| EXPECT_EQ(sent_events[0].direction, kUndefined); | ||
|
|
||
| view.OnFocus(kUnfocused); | ||
| view.OnFocus(kUnfocused); | ||
| ASSERT_EQ(sent_events.size(), 2u); | ||
| EXPECT_EQ(sent_events[1].state, kUnfocused); | ||
|
|
||
| FlutterViewFocusChangeRequest request = { | ||
| .struct_size = sizeof(FlutterViewFocusChangeRequest), | ||
| .view_id = kImplicitViewId, | ||
| .state = kUnfocused, | ||
| .direction = kUndefined, | ||
| }; | ||
| view.OnFocusChangeRequest(request); | ||
| EXPECT_FALSE(tizen_view_ptr->activated); | ||
|
|
||
| request.state = kFocused; | ||
| request.view_id = kImplicitViewId + 1; | ||
| view.OnFocusChangeRequest(request); | ||
| EXPECT_FALSE(tizen_view_ptr->activated); | ||
|
|
||
| request.view_id = kImplicitViewId; | ||
| view.OnFocusChangeRequest(request); | ||
| EXPECT_TRUE(tizen_view_ptr->activated); | ||
|
|
||
| tizen_view_ptr->activated = false; | ||
| tizen_view_ptr->SetFocusable(false); | ||
| view.OnFocus(kFocused); | ||
| EXPECT_EQ(sent_events.size(), 2u); | ||
| view.OnFocusChangeRequest(request); | ||
| EXPECT_FALSE(tizen_view_ptr->activated); | ||
| } | ||
| ecore_shutdown(); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace testing | ||
| } // namespace flutter |
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.