[modular] Use StoryInfo2 in tests

Bug: 16407

Change-Id: I673cffc50db28a050ab66e89b4b991192116a77d
diff --git a/peridot/bin/modular_test_harness/test_session_shell.cc b/peridot/bin/modular_test_harness/test_session_shell.cc
index 9b4e29a..1653276 100644
--- a/peridot/bin/modular_test_harness/test_session_shell.cc
+++ b/peridot/bin/modular_test_harness/test_session_shell.cc
@@ -28,8 +28,8 @@
 
     component_context->svc()->Connect(session_shell_context_.NewRequest());
     session_shell_context_->GetStoryProvider(story_provider_.NewRequest());
-    story_provider_->GetStories(story_provider_watcher_.NewBinding(),
-                                [](std::vector<fuchsia::modular::StoryInfo>) {});
+    story_provider_->GetStories2(story_provider_watcher_.NewBinding(),
+                                 [](std::vector<fuchsia::modular::StoryInfo2>) {});
 
     startup_context_ = component::StartupContext::CreateFromStartupInfo();
   }
@@ -59,8 +59,8 @@
   }
 
   // |fuchsia::modular::StoryProviderWatcher|
-  void OnChange(fuchsia::modular::StoryInfo story_info, fuchsia::modular::StoryState story_state,
-                fuchsia::modular::StoryVisibilityState story_visibility_state) override {}
+  void OnChange2(fuchsia::modular::StoryInfo2 story_info, fuchsia::modular::StoryState story_state,
+                 fuchsia::modular::StoryVisibilityState story_visibility_state) override {}
 
   // |fuchsia::modular::StoryProviderWatcher|
   void OnDelete(std::string story_id) override {}
diff --git a/peridot/lib/testing/story_controller_mock.h b/peridot/lib/testing/story_controller_mock.h
index 747c6af..ebdc6fd6 100644
--- a/peridot/lib/testing/story_controller_mock.h
+++ b/peridot/lib/testing/story_controller_mock.h
@@ -25,10 +25,9 @@
 
  private:
   // |fuchsia::modular::StoryController|
-  void GetInfo(GetInfoCallback callback) override {
-    fuchsia::modular::StoryInfo info;
-    info.id = "wow";
-    info.url = "wow";
+  void GetInfo2(GetInfo2Callback callback) override {
+    fuchsia::modular::StoryInfo2 info;
+    info.set_id("wow");
     callback(std::move(info), fuchsia::modular::StoryState::STOPPED);
   }
 
diff --git a/peridot/lib/testing/story_provider_mock.h b/peridot/lib/testing/story_provider_mock.h
index 2aac210..845f864 100644
--- a/peridot/lib/testing/story_provider_mock.h
+++ b/peridot/lib/testing/story_provider_mock.h
@@ -19,13 +19,13 @@
 class StoryProviderMock : public fuchsia::modular::StoryProvider {
  public:
   // Allows notification of watchers.
-  void NotifyStoryChanged(fuchsia::modular::StoryInfo story_info,
+  void NotifyStoryChanged(fuchsia::modular::StoryInfo2 story_info,
                           fuchsia::modular::StoryState story_state,
                           fuchsia::modular::StoryVisibilityState story_visibility_state) {
     for (const auto& watcher : watchers_.ptrs()) {
-      fuchsia::modular::StoryInfo story_info_clone;
+      fuchsia::modular::StoryInfo2 story_info_clone;
       fidl::Clone(story_info, &story_info_clone);
-      (*watcher)->OnChange(std::move(story_info_clone), story_state, story_visibility_state);
+      (*watcher)->OnChange2(std::move(story_info_clone), story_state, story_visibility_state);
     }
   }
 
@@ -41,9 +41,9 @@
 
  private:
   // |fuchsia::modular::StoryProvider|
-  void GetStories(fidl::InterfaceHandle<fuchsia::modular::StoryProviderWatcher> watcher,
-                  GetStoriesCallback callback) override {
-    std::vector<fuchsia::modular::StoryInfo> stories;
+  void GetStories2(fidl::InterfaceHandle<fuchsia::modular::StoryProviderWatcher> watcher,
+                   GetStories2Callback callback) override {
+    std::vector<fuchsia::modular::StoryInfo2> stories;
     callback(std::move(stories));
   }
 
@@ -59,8 +59,8 @@
   }
 
   // |fuchsia::modular::StoryProvider|
-  void GetStoryInfo(std::string story_id, GetStoryInfoCallback callback) override {
-    callback(nullptr);
+  void GetStoryInfo2(std::string story_id, GetStoryInfo2Callback callback) override {
+    callback(fuchsia::modular::StoryInfo2{});
   }
 
   // |fuchsia::modular::StoryProvider|
diff --git a/peridot/public/lib/modular_test_harness/cpp/fake_session_shell.h b/peridot/public/lib/modular_test_harness/cpp/fake_session_shell.h
index 1f06c50..8177249 100644
--- a/peridot/public/lib/modular_test_harness/cpp/fake_session_shell.h
+++ b/peridot/public/lib/modular_test_harness/cpp/fake_session_shell.h
@@ -6,6 +6,7 @@
 #define LIB_MODULAR_TEST_HARNESS_CPP_FAKE_SESSION_SHELL_H_
 
 #include <lib/modular_test_harness/cpp/fake_component.h>
+
 #include <sdk/lib/sys/cpp/component_context.h>
 
 #include "peridot/lib/testing/session_shell_impl.h"
@@ -73,9 +74,9 @@
 // // Add a function that does something when a story state change is observed.
 // const char[] kStoryId = "my_story";
 // modular::testing::SimpleStoryProviderWatcher watcher;
-// watcher.set_on_change([kStoryId](StoryInfo story_info,
-//                                  StoryState story_state,
-//                                  StoryVisibilityState _) {
+// watcher.set_on_change_2([kStoryId](StoryInfo2 story_info,
+//                                    StoryState story_state,
+//                                    StoryVisibilityState _) {
 //   EXPECT_EQ(story_info.id, kStoryId);
 // });
 // watcher.Watch(fake_session_shell.story_provider(),
@@ -85,16 +86,10 @@
   SimpleStoryProviderWatcher() : binding_(this) {}
   ~SimpleStoryProviderWatcher() override = default;
 
-  using OnChangeFunction =
-      fit::function<void(fuchsia::modular::StoryInfo, fuchsia::modular::StoryState,
-                         fuchsia::modular::StoryVisibilityState)>;
-
   using OnChange2Function =
       fit::function<void(fuchsia::modular::StoryInfo2, fuchsia::modular::StoryState,
                          fuchsia::modular::StoryVisibilityState)>;
 
-  void set_on_change(OnChangeFunction on_change) { on_change_ = std::move(on_change); }
-
   void set_on_change_2(OnChange2Function on_change_2) { on_change_2_ = std::move(on_change_2); }
 
   // Start watching for story state changes in the given story_provider. Takes
@@ -103,21 +98,15 @@
   // any existing stories when watching starts).
   void Watch(
       fuchsia::modular::StoryProvider* story_provider,
-      fit::function<void(std::vector<fuchsia::modular::StoryInfo> stories)>* on_get_stories) {
-    story_provider->GetStories(
+      fit::function<void(std::vector<fuchsia::modular::StoryInfo2> stories)>* on_get_stories) {
+    story_provider->GetStories2(
         binding_.NewBinding(), on_get_stories != nullptr
                                    ? std::move(*on_get_stories)
-                                   : [](std::vector<fuchsia::modular::StoryInfo>) {});
+                                   : [](std::vector<fuchsia::modular::StoryInfo2>) {});
   }
 
  private:
   // |fuchsia::modular::StoryProviderWatcher|
-  void OnChange(fuchsia::modular::StoryInfo story_info, fuchsia::modular::StoryState story_state,
-                fuchsia::modular::StoryVisibilityState story_visibility_state) override {
-    on_change_(std::move(story_info), story_state, story_visibility_state);
-  }
-
-  // |fuchsia::modular::StoryProviderWatcher|
   void OnChange2(fuchsia::modular::StoryInfo2 story_info, fuchsia::modular::StoryState story_state,
                  fuchsia::modular::StoryVisibilityState story_visibility_state) override {
     on_change_2_(std::move(story_info), story_state, story_visibility_state);
@@ -126,13 +115,7 @@
   // |fuchsia::modular::StoryProviderWatcher|
   void OnDelete(std::string story_id) override {}
 
-  // Optional user-provided lambda that will run with each OnChange(). Defaults
-  // to doing nothing.
-  OnChangeFunction on_change_ =
-      [](fuchsia::modular::StoryInfo story_info, fuchsia::modular::StoryState story_state,
-         fuchsia::modular::StoryVisibilityState story_visibility_state) {};
-
-  // Optional user-provided lambda that will run with each OnChange(). Defaults
+  // Optional user-provided lambda that will run with each OnChange2(). Defaults
   // to doing nothing.
   OnChange2Function on_change_2_ =
       [](fuchsia::modular::StoryInfo2 story_info, fuchsia::modular::StoryState story_state,
diff --git a/src/modular/benchmarks/story_benchmark.cc b/src/modular/benchmarks/story_benchmark.cc
index b3dba6e..3be01c6 100644
--- a/src/modular/benchmarks/story_benchmark.cc
+++ b/src/modular/benchmarks/story_benchmark.cc
@@ -266,8 +266,8 @@
     TRACE_ASYNC_BEGIN("benchmark", "story/info", 0);
 
     bool got_story_info{false};
-    story_controller_->GetInfo(
-        [&](fuchsia::modular::StoryInfo story_info, fuchsia::modular::StoryState state) {
+    story_controller_->GetInfo2(
+        [&](fuchsia::modular::StoryInfo2 story_info, fuchsia::modular::StoryState state) {
           TRACE_ASYNC_END("benchmark", "story/info", 0);
           got_story_info = true;
         });
diff --git a/src/modular/tests/last_focus_time_test.cc b/src/modular/tests/last_focus_time_test.cc
index a39dbf0..004cf856 100644
--- a/src/modular/tests/last_focus_time_test.cc
+++ b/src/modular/tests/last_focus_time_test.cc
@@ -52,8 +52,8 @@
   TestStoryProviderWatcher() : binding_(this) {}
   ~TestStoryProviderWatcher() override = default;
 
-  void OnChange(fit::function<void(fuchsia::modular::StoryInfo)> on_change) {
-    on_change_ = std::move(on_change);
+  void OnChange2(fit::function<void(fuchsia::modular::StoryInfo2)> on_change) {
+    on_change_2_ = std::move(on_change);
   }
 
   void Watch(fuchsia::modular::StoryProvider* const story_provider) {
@@ -65,13 +65,13 @@
   void OnDelete(::std::string story_id) override {}
 
   // |fuchsia::modular::StoryProviderWatcher|
-  void OnChange(fuchsia::modular::StoryInfo story_info, fuchsia::modular::StoryState story_state,
-                fuchsia::modular::StoryVisibilityState story_visibility_state) override {
-    on_change_(std::move(story_info));
+  void OnChange2(fuchsia::modular::StoryInfo2 story_info, fuchsia::modular::StoryState story_state,
+                 fuchsia::modular::StoryVisibilityState story_visibility_state) override {
+    on_change_2_(std::move(story_info));
     return;
   }
 
-  fit::function<void(fuchsia::modular::StoryInfo)> on_change_;
+  fit::function<void(fuchsia::modular::StoryInfo2)> on_change_2_;
   fidl::Binding<fuchsia::modular::StoryProviderWatcher> binding_;
 };
 
@@ -143,9 +143,11 @@
   // Keep track of the focus timestamps that we receive for the story created
   // below so we can assert that they make sense at the end of the test.
   std::vector<int64_t> last_focus_timestamps;
-  story_provider_watcher.OnChange([&](fuchsia::modular::StoryInfo story_info) {
-    ASSERT_EQ(kStoryName, story_info.id);
-    last_focus_timestamps.push_back(story_info.last_focus_time);
+  story_provider_watcher.OnChange2([&](fuchsia::modular::StoryInfo2 story_info) {
+    ASSERT_TRUE(story_info.has_id());
+    ASSERT_TRUE(story_info.has_last_focus_time());
+    ASSERT_EQ(kStoryName, story_info.id());
+    last_focus_timestamps.push_back(story_info.last_focus_time());
   });
 
   // Create a story so that we can signal the framework to focus it.
diff --git a/src/modular/tests/session_shell_test.cc b/src/modular/tests/session_shell_test.cc
index 87fe622..cedada7 100644
--- a/src/modular/tests/session_shell_test.cc
+++ b/src/modular/tests/session_shell_test.cc
@@ -74,11 +74,11 @@
   ASSERT_TRUE(story_provider != nullptr);
 
   bool tried_get_story_info = false;
-  story_provider->GetStoryInfo("X",
-                               [&tried_get_story_info](fuchsia::modular::StoryInfoPtr story_info) {
-                                 EXPECT_THAT(story_info, IsNull());
-                                 tried_get_story_info = true;
-                               });
+  story_provider->GetStoryInfo2("X",
+                                [&tried_get_story_info](fuchsia::modular::StoryInfo2 story_info) {
+                                  EXPECT_TRUE(story_info.IsEmpty());
+                                  tried_get_story_info = true;
+                                });
 
   RunLoopUntil([&] { return tried_get_story_info; });
 }
@@ -107,8 +107,8 @@
   ASSERT_TRUE(story_provider != nullptr);
 
   bool called_get_stories = false;
-  story_provider->GetStories(
-      nullptr, [&called_get_stories](std::vector<fuchsia::modular::StoryInfo> stories) {
+  story_provider->GetStories2(
+      nullptr, [&called_get_stories](const std::vector<fuchsia::modular::StoryInfo2>& stories) {
         EXPECT_THAT(stories, testing::IsEmpty());
         called_get_stories = true;
       });
@@ -136,9 +136,11 @@
   // and confirm that it only sees the correct story id.
   std::vector<StoryState> sequence_of_story_states;
   modular::testing::SimpleStoryProviderWatcher watcher;
-  watcher.set_on_change([&sequence_of_story_states, kStoryId](
-                            StoryInfo story_info, StoryState story_state, StoryVisibilityState _) {
-    EXPECT_EQ(story_info.id, kStoryId);
+  watcher.set_on_change_2([&sequence_of_story_states, kStoryId](StoryInfo2 story_info,
+                                                                StoryState story_state,
+                                                                StoryVisibilityState _) {
+    ASSERT_TRUE(story_info.has_id());
+    EXPECT_EQ(story_info.id(), kStoryId);
     sequence_of_story_states.push_back(story_state);
   });
   watcher.Watch(story_provider, /*on_get_stories=*/nullptr);
@@ -218,10 +220,10 @@
                          story_provider](fuchsia::modular::ExecuteResult result) {
     // Verify that the newly created story returns something for
     // GetStoryInfo().
-    story_provider->GetStoryInfo(kStoryId, [&execute_and_get_story_info_called,
-                                            kStoryId](fuchsia::modular::StoryInfoPtr story_info) {
-      ASSERT_THAT(story_info, Not(IsNull()));
-      EXPECT_EQ(story_info->id, kStoryId);
+    story_provider->GetStoryInfo2(kStoryId, [&execute_and_get_story_info_called,
+                                             kStoryId](fuchsia::modular::StoryInfo2 story_info) {
+      ASSERT_TRUE(story_info.has_id());
+      EXPECT_EQ(story_info.id(), kStoryId);
       execute_and_get_story_info_called = true;
     });
   });
@@ -230,8 +232,8 @@
   // Delete the story and confirm that the story info is null now.
   bool delete_called = false;
   puppet_master->DeleteStory(kStoryId, [&delete_called, kStoryId, story_provider] {
-    story_provider->GetStoryInfo(kStoryId, [](fuchsia::modular::StoryInfoPtr story_info) {
-      EXPECT_THAT(story_info, IsNull());
+    story_provider->GetStoryInfo2(kStoryId, [](fuchsia::modular::StoryInfo2 story_info) {
+      EXPECT_TRUE(story_info.IsEmpty());
     });
     delete_called = true;
   });
@@ -261,16 +263,16 @@
   story_master->SetCreateOptions(std::move(story_options));
 
   bool called_get_stories = false;
-  story_master->Execute(
-      [&called_get_stories, story_provider](fuchsia::modular::ExecuteResult result) {
-        // Confirm that even after the story is created, GetStories() returns
-        // empty.
-        story_provider->GetStories(
-            nullptr, [&called_get_stories](std::vector<fuchsia::modular::StoryInfo> stories) {
-              EXPECT_THAT(stories, testing::IsEmpty());
-              called_get_stories = true;
-            });
-      });
+  story_master->Execute([&called_get_stories,
+                         story_provider](fuchsia::modular::ExecuteResult result) {
+    // Confirm that even after the story is created, GetStories() returns
+    // empty.
+    story_provider->GetStories2(
+        nullptr, [&called_get_stories](const std::vector<fuchsia::modular::StoryInfo2>& stories) {
+          EXPECT_THAT(stories, testing::IsEmpty());
+          called_get_stories = true;
+        });
+  });
 
   RunLoopUntil([&] { return called_get_stories; });
 }
@@ -295,9 +297,11 @@
   // and confirm that it only sees the correct story id.
   std::vector<StoryState> sequence_of_story_states;
   modular::testing::SimpleStoryProviderWatcher watcher;
-  watcher.set_on_change([&sequence_of_story_states, kStoryId](
-                            StoryInfo story_info, StoryState story_state, StoryVisibilityState _) {
-    EXPECT_EQ(story_info.id, kStoryId);
+  watcher.set_on_change_2([&sequence_of_story_states, kStoryId](StoryInfo2 story_info,
+                                                                StoryState story_state,
+                                                                StoryVisibilityState _) {
+    EXPECT_TRUE(story_info.has_id());
+    EXPECT_EQ(story_info.id(), kStoryId);
     sequence_of_story_states.push_back(story_state);
   });
   watcher.Watch(story_provider, /*on_get_stories=*/nullptr);
@@ -365,9 +369,11 @@
   // and confirm that it only sees the correct story id.
   std::vector<StoryState> sequence_of_story_states;
   modular::testing::SimpleStoryProviderWatcher watcher;
-  watcher.set_on_change([&sequence_of_story_states, kStoryId](
-                            StoryInfo story_info, StoryState story_state, StoryVisibilityState _) {
-    EXPECT_EQ(story_info.id, kStoryId);
+  watcher.set_on_change_2([&sequence_of_story_states, kStoryId](StoryInfo2 story_info,
+                                                                StoryState story_state,
+                                                                StoryVisibilityState _) {
+    EXPECT_TRUE(story_info.has_id());
+    EXPECT_EQ(story_info.id(), kStoryId);
     sequence_of_story_states.push_back(story_state);
   });
   watcher.Watch(story_provider, /*on_get_stories=*/nullptr);