fix(omnibox): address review follow-ups
Keep standalone argv handling and favorite indicator updates aligned with the current UI behavior, and make detached process release failures non-fatal.
- commit
- 7fd7cd45d1edd3af4d298ff12c5d79ca38ed9614
- author
- brice · · 2026-04-07 18:58 UTC
- parent
- a25cbb9
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
7 files · +114 -8
M internal/infrastructure/desktop/adapter.go +4 -1
| @@ -432,7 +432,10 @@ func startDetachedProcess(cmd *exec.Cmd) error { | |||
| 432 | 432 | } | |
| 433 | 433 | if cmd.Process != nil { | |
| 434 | 434 | if err := cmd.Process.Release(); err != nil { | |
| 435 | - | return err | |
| 435 | + | logging.FromContext(context.Background()).Warn(). | |
| 436 | + | Err(err). | |
| 437 | + | Str("path", cmd.Path). | |
| 438 | + | Msg("startDetachedProcess: cmd.Process.Release failed after start (non-fatal)") | |
| 436 | 439 | } | |
| 437 | 440 | } | |
| 438 | 441 | ||
| @@ -432,7 +432,10 @@ func startDetachedProcess(cmd *exec.Cmd) error { | |||||
| 432 | } | 432 | } | ||
| 433 | if cmd.Process != nil { | 433 | if cmd.Process != nil { | ||
| 434 | if err := cmd.Process.Release(); err != nil { | 434 | if err := cmd.Process.Release(); err != nil { | ||
| 435 | - | return err | 435 | + | logging.FromContext(context.Background()).Warn(). |
| 436 | + | Err(err). | |||
| 437 | + | Str("path", cmd.Path). | |||
| 438 | + | Msg("startDetachedProcess: cmd.Process.Release failed after start (non-fatal)") | |||
| 436 | } | 439 | } | ||
| 437 | } | 440 | } | ||
| 438 | 441 | ||||
M internal/ui/component/omnibox.go +67 -5
| @@ -327,6 +327,10 @@ func resultsContainerState(rowCount int) (visible, expand, listVisible bool) { | |||
| 327 | 327 | return rowCount > 0, rowCount > 0, rowCount > 0 | |
| 328 | 328 | } | |
| 329 | 329 | ||
| 330 | + | func shouldApplyEmptyResultsState(rowCount int, visible bool) bool { | |
| 331 | + | return !visible || rowCount <= 0 | |
| 332 | + | } | |
| 333 | + | ||
| 330 | 334 | func (o *Omnibox) setResultsContainerState(rowCount int) { | |
| 331 | 335 | if o.scrolledWin == nil { | |
| 332 | 336 | return | |
| @@ -338,7 +342,11 @@ func (o *Omnibox) setResultsContainerState(rowCount int) { | |||
| 338 | 342 | o.listBox.SetVisible(listVisible) | |
| 339 | 343 | } | |
| 340 | 344 | if o.mainBox != nil { | |
| 341 | - | o.mainBox.RemoveCssClass("omnibox-empty") | |
| 345 | + | if shouldApplyEmptyResultsState(rowCount, visible) { | |
| 346 | + | o.mainBox.AddCssClass("omnibox-empty") | |
| 347 | + | } else { | |
| 348 | + | o.mainBox.RemoveCssClass("omnibox-empty") | |
| 349 | + | } | |
| 342 | 350 | } | |
| 343 | 351 | } | |
| 344 | 352 | ||
| @@ -1771,11 +1779,52 @@ func (o *Omnibox) createFaviconImage(rawURL, fallbackIcon string) *gtk.Image { | |||
| 1771 | 1779 | } | |
| 1772 | 1780 | ||
| 1773 | 1781 | const favoriteStarBaseSize = 18 | |
| 1782 | + | const favoriteStarSlotClass = "omnibox-favorite-star-slot" | |
| 1774 | 1783 | ||
| 1775 | 1784 | func favoriteStarSize(scale float64) int { return ScaleValue(favoriteStarBaseSize, scale) } | |
| 1776 | 1785 | ||
| 1777 | 1786 | func shouldShowFavoriteStar(s Suggestion) bool { return s.IsFavorite } | |
| 1778 | 1787 | ||
| 1788 | + | func clearBoxChildren(box *gtk.Box) { | |
| 1789 | + | if box == nil { | |
| 1790 | + | return | |
| 1791 | + | } | |
| 1792 | + | for child := box.GetFirstChild(); child != nil; { | |
| 1793 | + | next := child.GetNextSibling() | |
| 1794 | + | box.Remove(child) | |
| 1795 | + | child = next | |
| 1796 | + | } | |
| 1797 | + | } | |
| 1798 | + | ||
| 1799 | + | func (o *Omnibox) syncFavoriteStarSlot(slot *gtk.Box, showFavoriteStar bool) { | |
| 1800 | + | if slot == nil { | |
| 1801 | + | return | |
| 1802 | + | } | |
| 1803 | + | clearBoxChildren(slot) | |
| 1804 | + | if showFavoriteStar { | |
| 1805 | + | if star := o.createFavoriteStarIcon(); star != nil { | |
| 1806 | + | slot.Append(&star.Widget) | |
| 1807 | + | } | |
| 1808 | + | } | |
| 1809 | + | slot.SetVisible(showFavoriteStar) | |
| 1810 | + | } | |
| 1811 | + | ||
| 1812 | + | func favoriteStarSlotForRow(row *gtk.ListBoxRow) *gtk.Box { | |
| 1813 | + | if row == nil { | |
| 1814 | + | return nil | |
| 1815 | + | } | |
| 1816 | + | hbox := row.GetChild() | |
| 1817 | + | if hbox == nil { | |
| 1818 | + | return nil | |
| 1819 | + | } | |
| 1820 | + | for child := hbox.GetFirstChild(); child != nil; child = child.GetNextSibling() { | |
| 1821 | + | if child.HasCssClass(favoriteStarSlotClass) { | |
| 1822 | + | return gtk.BoxNewFromInternalPtr(child.GoPointer()) | |
| 1823 | + | } | |
| 1824 | + | } | |
| 1825 | + | return nil | |
| 1826 | + | } | |
| 1827 | + | ||
| 1779 | 1828 | func (o *Omnibox) createFavoriteStarIcon() *gtk.Image { | |
| 1780 | 1829 | star := gtk.NewImage() | |
| 1781 | 1830 | if star == nil { | |
| @@ -1817,10 +1866,12 @@ func (o *Omnibox) appendSuggestionTitleAndURL(textBox *gtk.Box, title, displayUR | |||
| 1817 | 1866 | } | |
| 1818 | 1867 | ||
| 1819 | 1868 | func (o *Omnibox) appendFavoriteStarAndShortcut(hbox *gtk.Box, showFavoriteStar bool, index int) { | |
| 1820 | - | if showFavoriteStar { | |
| 1821 | - | if star := o.createFavoriteStarIcon(); star != nil { | |
| 1822 | - | hbox.Append(&star.Widget) | |
| 1823 | - | } | |
| 1869 | + | starSlot := gtk.NewBox(gtk.OrientationHorizontalValue, 0) | |
| 1870 | + | if starSlot != nil { | |
| 1871 | + | starSlot.AddCssClass(favoriteStarSlotClass) | |
| 1872 | + | starSlot.SetValign(gtk.AlignCenterValue) | |
| 1873 | + | o.syncFavoriteStarSlot(starSlot, showFavoriteStar) | |
| 1874 | + | hbox.Append(&starSlot.Widget) | |
| 1824 | 1875 | } | |
| 1825 | 1876 | ||
| 1826 | 1877 | const maxShortcutIndex = 9 | |
| @@ -2256,6 +2307,17 @@ func (o *Omnibox) updateRowFavoriteIndicator(index int, isFavorite bool) { | |||
| 2256 | 2307 | } else { | |
| 2257 | 2308 | row.RemoveCssClass("omnibox-row-favorite") | |
| 2258 | 2309 | } | |
| 2310 | + | if slot := favoriteStarSlotForRow(row); slot != nil { | |
| 2311 | + | o.syncFavoriteStarSlot(slot, isFavorite) | |
| 2312 | + | slot.QueueDraw() | |
| 2313 | + | slot.Show() | |
| 2314 | + | } | |
| 2315 | + | if child := row.GetChild(); child != nil { | |
| 2316 | + | child.QueueDraw() | |
| 2317 | + | child.Show() | |
| 2318 | + | } | |
| 2319 | + | row.QueueDraw() | |
| 2320 | + | row.Show() | |
| 2259 | 2321 | } | |
| 2260 | 2322 | ||
| 2261 | 2323 | // yankSelectedURL copies the URL of the selected item to clipboard. | |
| @@ -327,6 +327,10 @@ func resultsContainerState(rowCount int) (visible, expand, listVisible bool) { | |||||
| 327 | return rowCount > 0, rowCount > 0, rowCount > 0 | 327 | return rowCount > 0, rowCount > 0, rowCount > 0 | ||
| 328 | } | 328 | } | ||
| 329 | 329 | ||||
| 330 | + | func shouldApplyEmptyResultsState(rowCount int, visible bool) bool { | |||
| 331 | + | return !visible || rowCount <= 0 | |||
| 332 | + | } | |||
| 333 | + | ||||
| 330 | func (o *Omnibox) setResultsContainerState(rowCount int) { | 334 | func (o *Omnibox) setResultsContainerState(rowCount int) { | ||
| 331 | if o.scrolledWin == nil { | 335 | if o.scrolledWin == nil { | ||
| 332 | return | 336 | return | ||
| @@ -338,7 +342,11 @@ func (o *Omnibox) setResultsContainerState(rowCount int) { | |||||
| 338 | o.listBox.SetVisible(listVisible) | 342 | o.listBox.SetVisible(listVisible) | ||
| 339 | } | 343 | } | ||
| 340 | if o.mainBox != nil { | 344 | if o.mainBox != nil { | ||
| 341 | - | o.mainBox.RemoveCssClass("omnibox-empty") | 345 | + | if shouldApplyEmptyResultsState(rowCount, visible) { |
| 346 | + | o.mainBox.AddCssClass("omnibox-empty") | |||
| 347 | + | } else { | |||
| 348 | + | o.mainBox.RemoveCssClass("omnibox-empty") | |||
| 349 | + | } | |||
| 342 | } | 350 | } | ||
| 343 | } | 351 | } | ||
| 344 | 352 | ||||
| @@ -1771,11 +1779,52 @@ func (o *Omnibox) createFaviconImage(rawURL, fallbackIcon string) *gtk.Image { | |||||
| 1771 | } | 1779 | } | ||
| 1772 | 1780 | ||||
| 1773 | const favoriteStarBaseSize = 18 | 1781 | const favoriteStarBaseSize = 18 | ||
| 1782 | + | const favoriteStarSlotClass = "omnibox-favorite-star-slot" | |||
| 1774 | 1783 | ||||
| 1775 | func favoriteStarSize(scale float64) int { return ScaleValue(favoriteStarBaseSize, scale) } | 1784 | func favoriteStarSize(scale float64) int { return ScaleValue(favoriteStarBaseSize, scale) } | ||
| 1776 | 1785 | ||||
| 1777 | func shouldShowFavoriteStar(s Suggestion) bool { return s.IsFavorite } | 1786 | func shouldShowFavoriteStar(s Suggestion) bool { return s.IsFavorite } | ||
| 1778 | 1787 | ||||
| 1788 | + | func clearBoxChildren(box *gtk.Box) { | |||
| 1789 | + | if box == nil { | |||
| 1790 | + | return | |||
| 1791 | + | } | |||
| 1792 | + | for child := box.GetFirstChild(); child != nil; { | |||
| 1793 | + | next := child.GetNextSibling() | |||
| 1794 | + | box.Remove(child) | |||
| 1795 | + | child = next | |||
| 1796 | + | } | |||
| 1797 | + | } | |||
| 1798 | + | ||||
| 1799 | + | func (o *Omnibox) syncFavoriteStarSlot(slot *gtk.Box, showFavoriteStar bool) { | |||
| 1800 | + | if slot == nil { | |||
| 1801 | + | return | |||
| 1802 | + | } | |||
| 1803 | + | clearBoxChildren(slot) | |||
| 1804 | + | if showFavoriteStar { | |||
| 1805 | + | if star := o.createFavoriteStarIcon(); star != nil { | |||
| 1806 | + | slot.Append(&star.Widget) | |||
| 1807 | + | } | |||
| 1808 | + | } | |||
| 1809 | + | slot.SetVisible(showFavoriteStar) | |||
| 1810 | + | } | |||
| 1811 | + | ||||
| 1812 | + | func favoriteStarSlotForRow(row *gtk.ListBoxRow) *gtk.Box { | |||
| 1813 | + | if row == nil { | |||
| 1814 | + | return nil | |||
| 1815 | + | } | |||
| 1816 | + | hbox := row.GetChild() | |||
| 1817 | + | if hbox == nil { | |||
| 1818 | + | return nil | |||
| 1819 | + | } | |||
| 1820 | + | for child := hbox.GetFirstChild(); child != nil; child = child.GetNextSibling() { | |||
| 1821 | + | if child.HasCssClass(favoriteStarSlotClass) { | |||
| 1822 | + | return gtk.BoxNewFromInternalPtr(child.GoPointer()) | |||
| 1823 | + | } | |||
| 1824 | + | } | |||
| 1825 | + | return nil | |||
| 1826 | + | } | |||
| 1827 | + | ||||
| 1779 | func (o *Omnibox) createFavoriteStarIcon() *gtk.Image { | 1828 | func (o *Omnibox) createFavoriteStarIcon() *gtk.Image { | ||
| 1780 | star := gtk.NewImage() | 1829 | star := gtk.NewImage() | ||
| 1781 | if star == nil { | 1830 | if star == nil { | ||
| @@ -1817,10 +1866,12 @@ func (o *Omnibox) appendSuggestionTitleAndURL(textBox *gtk.Box, title, displayUR | |||||
| 1817 | } | 1866 | } | ||
| 1818 | 1867 | ||||
| 1819 | func (o *Omnibox) appendFavoriteStarAndShortcut(hbox *gtk.Box, showFavoriteStar bool, index int) { | 1868 | func (o *Omnibox) appendFavoriteStarAndShortcut(hbox *gtk.Box, showFavoriteStar bool, index int) { | ||
| 1820 | - | if showFavoriteStar { | 1869 | + | starSlot := gtk.NewBox(gtk.OrientationHorizontalValue, 0) |
| 1821 | - | if star := o.createFavoriteStarIcon(); star != nil { | 1870 | + | if starSlot != nil { |
| 1822 | - | hbox.Append(&star.Widget) | 1871 | + | starSlot.AddCssClass(favoriteStarSlotClass) |
| 1823 | - | } | 1872 | + | starSlot.SetValign(gtk.AlignCenterValue) |
| 1873 | + | o.syncFavoriteStarSlot(starSlot, showFavoriteStar) | |||
| 1874 | + | hbox.Append(&starSlot.Widget) | |||
| 1824 | } | 1875 | } | ||
| 1825 | 1876 | ||||
| 1826 | const maxShortcutIndex = 9 | 1877 | const maxShortcutIndex = 9 | ||
| @@ -2256,6 +2307,17 @@ func (o *Omnibox) updateRowFavoriteIndicator(index int, isFavorite bool) { | |||||
| 2256 | } else { | 2307 | } else { | ||
| 2257 | row.RemoveCssClass("omnibox-row-favorite") | 2308 | row.RemoveCssClass("omnibox-row-favorite") | ||
| 2258 | } | 2309 | } | ||
| 2310 | + | if slot := favoriteStarSlotForRow(row); slot != nil { | |||
| 2311 | + | o.syncFavoriteStarSlot(slot, isFavorite) | |||
| 2312 | + | slot.QueueDraw() | |||
| 2313 | + | slot.Show() | |||
| 2314 | + | } | |||
| 2315 | + | if child := row.GetChild(); child != nil { | |||
| 2316 | + | child.QueueDraw() | |||
| 2317 | + | child.Show() | |||
| 2318 | + | } | |||
| 2319 | + | row.QueueDraw() | |||
| 2320 | + | row.Show() | |||
| 2259 | } | 2321 | } | ||
| 2260 | 2322 | ||||
| 2261 | // yankSelectedURL copies the URL of the selected item to clipboard. | 2323 | // yankSelectedURL copies the URL of the selected item to clipboard. | ||
M internal/ui/component/omnibox_favorite_icon_test.go +19 -0
| @@ -15,3 +15,22 @@ func TestOmniboxFavoriteStarVisibility(t *testing.T) { | |||
| 15 | 15 | assert.True(t, shouldShowFavoriteStar(Suggestion{IsFavorite: true})) | |
| 16 | 16 | assert.False(t, shouldShowFavoriteStar(Suggestion{IsFavorite: false})) | |
| 17 | 17 | } | |
| 18 | + | ||
| 19 | + | func TestShouldApplyEmptyResultsState(t *testing.T) { | |
| 20 | + | tests := []struct { | |
| 21 | + | name string | |
| 22 | + | rowCount int | |
| 23 | + | visible bool | |
| 24 | + | want bool | |
| 25 | + | }{ | |
| 26 | + | {name: "negative rows uses empty state", rowCount: -1, visible: false, want: true}, | |
| 27 | + | {name: "zero rows uses empty state", rowCount: 0, visible: false, want: true}, | |
| 28 | + | {name: "positive rows clears empty state", rowCount: 2, visible: true, want: false}, | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | for _, tt := range tests { | |
| 32 | + | t.Run(tt.name, func(t *testing.T) { | |
| 33 | + | assert.Equal(t, tt.want, shouldApplyEmptyResultsState(tt.rowCount, tt.visible)) | |
| 34 | + | }) | |
| 35 | + | } | |
| 36 | + | } | |
| @@ -15,3 +15,22 @@ func TestOmniboxFavoriteStarVisibility(t *testing.T) { | |||||
| 15 | assert.True(t, shouldShowFavoriteStar(Suggestion{IsFavorite: true})) | 15 | assert.True(t, shouldShowFavoriteStar(Suggestion{IsFavorite: true})) | ||
| 16 | assert.False(t, shouldShowFavoriteStar(Suggestion{IsFavorite: false})) | 16 | assert.False(t, shouldShowFavoriteStar(Suggestion{IsFavorite: false})) | ||
| 17 | } | 17 | } | ||
| 18 | + | ||||
| 19 | + | func TestShouldApplyEmptyResultsState(t *testing.T) { | |||
| 20 | + | tests := []struct { | |||
| 21 | + | name string | |||
| 22 | + | rowCount int | |||
| 23 | + | visible bool | |||
| 24 | + | want bool | |||
| 25 | + | }{ | |||
| 26 | + | {name: "negative rows uses empty state", rowCount: -1, visible: false, want: true}, | |||
| 27 | + | {name: "zero rows uses empty state", rowCount: 0, visible: false, want: true}, | |||
| 28 | + | {name: "positive rows clears empty state", rowCount: 2, visible: true, want: false}, | |||
| 29 | + | } | |||
| 30 | + | ||||
| 31 | + | for _, tt := range tests { | |||
| 32 | + | t.Run(tt.name, func(t *testing.T) { | |||
| 33 | + | assert.Equal(t, tt.want, shouldApplyEmptyResultsState(tt.rowCount, tt.visible)) | |||
| 34 | + | }) | |||
| 35 | + | } | |||
| 36 | + | } | |||
M internal/ui/component/omnibox_navigation_state_test.go +1 -0
| @@ -95,6 +95,7 @@ func TestResultsContainerState(t *testing.T) { | |||
| 95 | 95 | wantExpand bool | |
| 96 | 96 | wantListVisible bool | |
| 97 | 97 | }{ | |
| 98 | + | {name: "negative rows stays hidden", rowCount: -1, wantVisible: false, wantExpand: false, wantListVisible: false}, | |
| 98 | 99 | {name: "no rows stays hidden", rowCount: 0, wantVisible: false, wantExpand: false, wantListVisible: false}, | |
| 99 | 100 | {name: "rows show and expand", rowCount: 3, wantVisible: true, wantExpand: true, wantListVisible: true}, | |
| 100 | 101 | } | |
| @@ -95,6 +95,7 @@ func TestResultsContainerState(t *testing.T) { | |||||
| 95 | wantExpand bool | 95 | wantExpand bool | ||
| 96 | wantListVisible bool | 96 | wantListVisible bool | ||
| 97 | }{ | 97 | }{ | ||
| 98 | + | {name: "negative rows stays hidden", rowCount: -1, wantVisible: false, wantExpand: false, wantListVisible: false}, | |||
| 98 | {name: "no rows stays hidden", rowCount: 0, wantVisible: false, wantExpand: false, wantListVisible: false}, | 99 | {name: "no rows stays hidden", rowCount: 0, wantVisible: false, wantExpand: false, wantListVisible: false}, | ||
| 99 | {name: "rows show and expand", rowCount: 3, wantVisible: true, wantExpand: true, wantListVisible: true}, | 100 | {name: "rows show and expand", rowCount: 3, wantVisible: true, wantExpand: true, wantListVisible: true}, | ||
| 100 | } | 101 | } | ||
M internal/ui/standalone_omnibox.go +3 -1
| @@ -84,9 +84,11 @@ func standaloneOmniboxArgv(args []string) []string { | |||
| 84 | 84 | } | |
| 85 | 85 | ||
| 86 | 86 | filtered := []string{args[0]} | |
| 87 | + | subcommandSkipped := false | |
| 87 | 88 | for i := 1; i < len(args); i++ { | |
| 88 | 89 | arg := args[i] | |
| 89 | - | if arg == "omnibox" { | |
| 90 | + | if arg == "omnibox" && !subcommandSkipped { | |
| 91 | + | subcommandSkipped = true | |
| 90 | 92 | continue | |
| 91 | 93 | } | |
| 92 | 94 | if strings.HasPrefix(arg, "-test.") { | |
| @@ -84,9 +84,11 @@ func standaloneOmniboxArgv(args []string) []string { | |||||
| 84 | } | 84 | } | ||
| 85 | 85 | ||||
| 86 | filtered := []string{args[0]} | 86 | filtered := []string{args[0]} | ||
| 87 | + | subcommandSkipped := false | |||
| 87 | for i := 1; i < len(args); i++ { | 88 | for i := 1; i < len(args); i++ { | ||
| 88 | arg := args[i] | 89 | arg := args[i] | ||
| 89 | - | if arg == "omnibox" { | 90 | + | if arg == "omnibox" && !subcommandSkipped { |
| 91 | + | subcommandSkipped = true | |||
| 90 | continue | 92 | continue | ||
| 91 | } | 93 | } | ||
| 92 | if strings.HasPrefix(arg, "-test.") { | 94 | if strings.HasPrefix(arg, "-test.") { | ||
M internal/ui/standalone_omnibox_test.go +17 -0
| @@ -158,6 +158,23 @@ func TestStandaloneOmniboxArgv_RemovesGoTestFlags(t *testing.T) { | |||
| 158 | 158 | } | |
| 159 | 159 | } | |
| 160 | 160 | ||
| 161 | + | func TestStandaloneOmniboxArgv_RemovesOnlyLeadingOmniboxSubcommand(t *testing.T) { | |
| 162 | + | argv := standaloneOmniboxArgv([]string{"/tmp/testbin", "omnibox", "https://example.com/omnibox", "omnibox"}) | |
| 163 | + | ||
| 164 | + | if len(argv) != 3 { | |
| 165 | + | t.Fatalf("expected 3 args, got %d: %#v", len(argv), argv) | |
| 166 | + | } | |
| 167 | + | if argv[0] != "/tmp/testbin" { | |
| 168 | + | t.Fatalf("expected binary path to be preserved, got %q", argv[0]) | |
| 169 | + | } | |
| 170 | + | if argv[1] != "https://example.com/omnibox" { | |
| 171 | + | t.Fatalf("expected non-subcommand omnibox value to be preserved, got %#v", argv) | |
| 172 | + | } | |
| 173 | + | if argv[2] != "omnibox" { | |
| 174 | + | t.Fatalf("expected later omnibox arg to be preserved, got %#v", argv) | |
| 175 | + | } | |
| 176 | + | } | |
| 177 | + | ||
| 161 | 178 | func TestTryInitLayerShell_NilWindowReturnsFalse(t *testing.T) { | |
| 162 | 179 | if tryInitLayerShell(nil, DefaultStandaloneOmniboxWindowConfig()) { | |
| 163 | 180 | t.Fatalf("expected nil window to skip layer-shell") | |
| @@ -158,6 +158,23 @@ func TestStandaloneOmniboxArgv_RemovesGoTestFlags(t *testing.T) { | |||||
| 158 | } | 158 | } | ||
| 159 | } | 159 | } | ||
| 160 | 160 | ||||
| 161 | + | func TestStandaloneOmniboxArgv_RemovesOnlyLeadingOmniboxSubcommand(t *testing.T) { | |||
| 162 | + | argv := standaloneOmniboxArgv([]string{"/tmp/testbin", "omnibox", "https://example.com/omnibox", "omnibox"}) | |||
| 163 | + | ||||
| 164 | + | if len(argv) != 3 { | |||
| 165 | + | t.Fatalf("expected 3 args, got %d: %#v", len(argv), argv) | |||
| 166 | + | } | |||
| 167 | + | if argv[0] != "/tmp/testbin" { | |||
| 168 | + | t.Fatalf("expected binary path to be preserved, got %q", argv[0]) | |||
| 169 | + | } | |||
| 170 | + | if argv[1] != "https://example.com/omnibox" { | |||
| 171 | + | t.Fatalf("expected non-subcommand omnibox value to be preserved, got %#v", argv) | |||
| 172 | + | } | |||
| 173 | + | if argv[2] != "omnibox" { | |||
| 174 | + | t.Fatalf("expected later omnibox arg to be preserved, got %#v", argv) | |||
| 175 | + | } | |||
| 176 | + | } | |||
| 177 | + | ||||
| 161 | func TestTryInitLayerShell_NilWindowReturnsFalse(t *testing.T) { | 178 | func TestTryInitLayerShell_NilWindowReturnsFalse(t *testing.T) { | ||
| 162 | if tryInitLayerShell(nil, DefaultStandaloneOmniboxWindowConfig()) { | 179 | if tryInitLayerShell(nil, DefaultStandaloneOmniboxWindowConfig()) { | ||
| 163 | t.Fatalf("expected nil window to skip layer-shell") | 180 | t.Fatalf("expected nil window to skip layer-shell") | ||
M internal/ui/theme/css_test.go +3 -1
| @@ -1,6 +1,7 @@ | |||
| 1 | 1 | package theme | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | + | "regexp" | |
| 4 | 5 | "strings" | |
| 5 | 6 | "testing" | |
| 6 | 7 | ) | |
| @@ -11,7 +12,8 @@ func TestGenerateCSS_StandaloneOmniboxWindowUsesTransparentBackground(t *testing | |||
| 11 | 12 | if !strings.Contains(css, "window.standalone-omnibox-window") { | |
| 12 | 13 | t.Fatalf("expected standalone omnibox window selector in CSS, got %q", css) | |
| 13 | 14 | } | |
| 14 | - | if !strings.Contains(css, "window.standalone-omnibox-window {\n\tbackground-color: transparent;") { | |
| 15 | + | re := regexp.MustCompile(`window\.standalone-omnibox-window\s*\{\s*background-color:\s*transparent\s*;?\s*\}`) | |
| 16 | + | if !re.MatchString(css) { | |
| 15 | 17 | t.Fatalf("expected standalone omnibox window background to be transparent") | |
| 16 | 18 | } | |
| 17 | 19 | } | |
| @@ -1,6 +1,7 @@ | |||||
| 1 | package theme | 1 | package theme | ||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | + | "regexp" | |||
| 4 | "strings" | 5 | "strings" | ||
| 5 | "testing" | 6 | "testing" | ||
| 6 | ) | 7 | ) | ||
| @@ -11,7 +12,8 @@ func TestGenerateCSS_StandaloneOmniboxWindowUsesTransparentBackground(t *testing | |||||
| 11 | if !strings.Contains(css, "window.standalone-omnibox-window") { | 12 | if !strings.Contains(css, "window.standalone-omnibox-window") { | ||
| 12 | t.Fatalf("expected standalone omnibox window selector in CSS, got %q", css) | 13 | t.Fatalf("expected standalone omnibox window selector in CSS, got %q", css) | ||
| 13 | } | 14 | } | ||
| 14 | - | if !strings.Contains(css, "window.standalone-omnibox-window {\n\tbackground-color: transparent;") { | 15 | + | re := regexp.MustCompile(`window\.standalone-omnibox-window\s*\{\s*background-color:\s*transparent\s*;?\s*\}`) |
| 16 | + | if !re.MatchString(css) { | |||
| 15 | t.Fatalf("expected standalone omnibox window background to be transparent") | 17 | t.Fatalf("expected standalone omnibox window background to be transparent") | ||
| 16 | } | 18 | } | ||
| 17 | } | 19 | } | ||