[ios] Fix Showcase

Remove reference to classes that now longer exists (they were removed
in https://crrev.com/c/1015541 and https://crrev.com/c/2053516). Add
a DCHECK that all classes registered in -[Showcase model] exists to
catch those errors next time.

Bug: none
Change-Id: I35d250257a7342e0f7561df65ee0bba7db4ecd38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2844578
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#875140}
GitOrigin-RevId: 81dfac6961cce7c1df7ee2623aa498ea79ce6933
diff --git a/showcase/core/showcase_model.mm b/showcase/core/showcase_model.mm
index d782bcf..2e0c166 100644
--- a/showcase/core/showcase_model.mm
+++ b/showcase/core/showcase_model.mm
@@ -4,12 +4,43 @@
 
 #import "ios/showcase/core/showcase_model.h"
 
+#include "base/check.h"
 #import "ios/showcase/core/showcase_model_buildflags.h"
 
 #if !defined(__has_feature) || !__has_feature(objc_arc)
 #error "This file requires ARC support."
 #endif
 
+namespace {
+
+// Validates whether all classes referenced by name in |row| can be loaded
+// using Objective-C reflection.
+BOOL IsShowcaseModelRowValid(showcase::ModelRow* row) {
+  static NSArray<NSString*>* const keys =
+      @[ showcase::kClassForInstantiationKey ];
+
+  BOOL valid = YES;
+  for (NSString* key in keys) {
+    if (!NSClassFromString(row[key])) {
+      NSLog(@"Can't load class: %@", row[key]);
+      valid = NO;
+    }
+  }
+  return valid;
+}
+
+// Validates whether all row in |model| are valid.
+BOOL IsShowcaseModelValid(NSArray<showcase::ModelRow*>* model) {
+  BOOL valid = YES;
+  for (showcase::ModelRow* row in model) {
+    if (!IsShowcaseModelRowValid(row))
+      valid = NO;
+  }
+  return valid;
+}
+
+}  // namespace
+
 @implementation ShowcaseModel
 
 // Insert additional rows in this array. All rows will be sorted upon
@@ -17,7 +48,7 @@
 // |kShowcaseClassForDisplayKey| and |kShowcaseClassForInstantiationKey| are
 // required. |kShowcaseUseCaseKey| is optional.
 + (NSArray<showcase::ModelRow*>*)model {
-  return @[
+  NSArray<showcase::ModelRow*>* model = @[
     @{
       showcase::kClassForDisplayKey : @"ConsentViewController",
       showcase::kClassForInstantiationKey : @"ConsentViewController",
@@ -46,21 +77,6 @@
       showcase::kUseCaseKey : @"Content Suggestions UI",
     },
     @{
-      showcase::kClassForDisplayKey : @"PaymentRequestEditViewController",
-      showcase::kClassForInstantiationKey : @"SCPaymentsEditorCoordinator",
-      showcase::kUseCaseKey : @"Generic payment request editor",
-    },
-    @{
-      showcase::kClassForDisplayKey : @"PaymentRequestPickerViewController",
-      showcase::kClassForInstantiationKey : @"SCPaymentsPickerCoordinator",
-      showcase::kUseCaseKey : @"Payment request picker view",
-    },
-    @{
-      showcase::kClassForDisplayKey : @"PaymentRequestSelectorViewController",
-      showcase::kClassForInstantiationKey : @"SCPaymentsSelectorCoordinator",
-      showcase::kUseCaseKey : @"Payment request selector view",
-    },
-    @{
       showcase::kClassForDisplayKey : @"SettingsViewController",
       showcase::kClassForInstantiationKey : @"SCSettingsCoordinator",
       showcase::kUseCaseKey : @"Main settings screen",
@@ -116,11 +132,6 @@
       showcase::kUseCaseKey : @"Toolbars for tab grid",
     },
     @{
-      showcase::kClassForDisplayKey : @"TableContainerViewController",
-      showcase::kClassForInstantiationKey : @"SCTableContainerCoordinator",
-      showcase::kUseCaseKey : @"Table View",
-    },
-    @{
       showcase::kClassForDisplayKey : @"TopAlignedImageView",
       showcase::kClassForInstantiationKey : @"SCImageViewController",
       showcase::kUseCaseKey : @"ImageView with top aligned aspect fill",
@@ -192,6 +203,8 @@
       showcase::kUseCaseKey : @"New FRE screen with scrolling example",
     },
   ];
+  DCHECK(IsShowcaseModelValid(model));
+  return model;
 }
 
 @end