This commit is contained in:
ponzischeme89
2026-08-22 18:40:50 +12:00
parent 9858e44710
commit 7d77700c7b
36 changed files with 480 additions and 119 deletions
+7 -2
View File
@@ -56,8 +56,9 @@ type RemoteConfigFeatures struct {
}
type RemoteConfigPresentation struct {
NavigationRailExpandedWidthDp int `json:"navigationRailExpandedWidthDp"`
NavigationContentShiftDp int `json:"navigationContentShiftDp"`
NavigationRailExpandedWidthDp int `json:"navigationRailExpandedWidthDp"`
NavigationContentShiftDp int `json:"navigationContentShiftDp"`
FontFamily string `json:"fontFamily"`
}
// The remainder of the document is deliberately declarative. A new server-side row or
@@ -160,6 +161,7 @@ func DefaultRemoteConfig() RemoteConfig {
Presentation: RemoteConfigPresentation{
NavigationRailExpandedWidthDp: 184,
NavigationContentShiftDp: 112,
FontFamily: "system",
},
Home: RemoteHomeConfig{
Sections: []string{"continue", "for-you", "favorites", "latest-movies"},
@@ -262,6 +264,9 @@ func validateRemoteConfig(document RemoteConfig) error {
if shift < 80 || shift > 160 || shift >= width {
return fmt.Errorf("navigationContentShiftDp must be between 80 and 160 and less than the rail width")
}
if document.Presentation.FontFamily != "system" && document.Presentation.FontFamily != "inter" {
return fmt.Errorf("fontFamily must be system or inter")
}
if err := validateRemoteConfigSections(document); err != nil {
return err
}
@@ -19,6 +19,9 @@ func TestRemoteConfigDefaultsAreComplete(t *testing.T) {
if !document.ContinueWatching.IncludeNextUp || len(document.Home.Sections) == 0 {
t.Fatalf("central defaults are incomplete: %+v", document)
}
if document.Presentation.FontFamily != "system" {
t.Fatalf("font family = %q, want system", document.Presentation.FontFamily)
}
}
func TestRemoteConfigDefaultsMissingNewSectionsForOlderDocuments(t *testing.T) {
@@ -47,6 +50,16 @@ func TestRemoteConfigRejectsMalformedAndUnsafeDocuments(t *testing.T) {
t.Fatal("unknown fields were accepted")
}
document = DefaultRemoteConfig()
document.Presentation.FontFamily = "comic-sans"
raw, err = json.Marshal(document)
if err != nil {
t.Fatal(err)
}
if _, err := loadRemoteConfig(string(raw)); err == nil {
t.Fatal("unknown font family was accepted")
}
document = DefaultRemoteConfig()
document.MinimumAppVersion = "0.3.0"
document.MaximumAppVersion = "0.2.54"