interfaces.go RawHistoryFolder
1package browser
2
3import (
4 "github.com/bnema/dumber/internal/app/messaging"
5 "github.com/bnema/dumber/pkg/webkit"
6)
7
8//go:generate mockgen -source=interfaces.go -destination=mocks/mock_browser.go -package=mock_browser
9
10// WebViewInterface abstracts WebKit WebView for testing
11type WebViewInterface interface {
12 LoadURL(url string) error
13 Show() error
14 Hide() error
15 Destroy() error
16 Window() *webkit.Window
17 GetCurrentURL() string
18 Widget() uintptr
19 RootWidget() uintptr
20 InjectScript(script string) error
21 DispatchCustomEvent(event string, detail map[string]any) error
22 RegisterKeyboardShortcut(key string, handler func()) error
23 RegisterURIChangedHandler(handler func(string))
24}
25
26// PaneInterface abstracts BrowserPane for testing
27type PaneInterface interface {
28 WebView() WebViewInterface
29 MessageHandler() MessageHandlerInterface
30 NavigationController() NavigationControllerInterface
31 ZoomController() ZoomControllerInterface
32 ClipboardController() ClipboardControllerInterface
33 ShortcutHandler() ShortcutHandlerInterface
34 ID() string
35 HasGUI() bool
36 SetHasGUI(bool)
37 SetID(string)
38 UpdateLastFocus()
39 HasGUIComponent(component string) bool
40 SetGUIComponent(component string, loaded bool)
41 Cleanup()
42}
43
44// MessageHandlerInterface abstracts messaging.Handler
45type MessageHandlerInterface interface {
46 SetWorkspaceObserver(observer messaging.WorkspaceObserver)
47}
48
49// NavigationControllerInterface abstracts navigation operations
50type NavigationControllerInterface interface {
51 NavigateToURL(url string) error
52}
53
54// ZoomControllerInterface abstracts zoom operations
55type ZoomControllerInterface interface {
56 ApplyInitialZoom()
57}
58
59// ClipboardControllerInterface abstracts clipboard operations
60type ClipboardControllerInterface interface {
61 // Add methods as needed
62}
63
64// ShortcutHandlerInterface abstracts shortcut handling
65type ShortcutHandlerInterface interface {
66 // Add methods as needed
67}
68
69// BrowserAppInterface abstracts BrowserApp for testing
70type BrowserAppInterface interface {
71 GetPanes() []*BrowserPane
72 SetActivePane(pane *BrowserPane)
73 GetActivePane() *BrowserPane
74 AppendPane(pane *BrowserPane)
75 RemovePane(pane *BrowserPane)
76 BuildWebkitConfig() (*webkit.Config, error)
77 CreatePaneForView(view *webkit.WebView) (*BrowserPane, error)
78}
79
80// WindowInterface abstracts webkit.Window for testing
81type WindowInterface interface {
82 SetChild(widget uintptr)
83}
84
85// WindowShortcutHandlerInterface abstracts window shortcut handling for testing
86type WindowShortcutHandlerInterface interface {
87 Cleanup()
88}