src/modular/bin/sessionmgr/storage/session_storage_unittest.cc
// Verifies that an on_annotations_updated callback registered with a particular story_id
// is invoked when only that story's annotations are updated.
Verifies that an on_annotations_updated callback registered with a particular story_id
is invoked when only that story's annotations are updated.
Verifies that an on_annotations_updated callback registered with a particular story_id is invoked when only that story ' s annotations are updated .
TEST_F(SessionStorageTest, OnAnnotationsUpdatedMultipleStories) {
  static constexpr auto story_name = "story-updated";
  static constexpr auto story_name_no_update = "story-not-updated";
  auto storage = CreateStorage();
  storage->CreateStory(story_name, {});
  storage->add_on_annotations_updated_once(
      story_name_no_update,
      [&](std::string story_id, std::vector<fuchsia::modular::Annotation> annotations) {
        FX_NOTREACHED() << "Callback called for story " << story_id << " but was registered for "
                        << story_name_no_update;
      });
  bool updated{};
  storage->add_on_annotations_updated_once(
      story_name, [&](std::string story_id, std::vector<fuchsia::modular::Annotation> annotations) {
        updated = true;
      });
  std::vector<fuchsia::modular::Annotation> annotations{};
  fuchsia::modular::AnnotationValue annotation_value;
  annotation_value.set_text("test_annotation_value");
  auto annotation = fuchsia::modular::Annotation{
      .key = "test_annotation_key", .value = fidl::MakeOptional(std::move(annotation_value))};
  annotations.push_back(fidl::Clone(annotation));
  storage->MergeStoryAnnotations(story_name, std::move(annotations));
  EXPECT_TRUE(updated);
}
TEST_F ( SessionStorageTest , OnAnnotationsUpdatedMultipleStories ) { static constexpr auto story_name = " " ; static constexpr auto story_name_no_update = " " ; auto storage = CreateStorage ( ) ; storage -> CreateStory ( story_name , { } ) ; storage -> add_on_annotations_updated_once ( story_name_no_update , [ & ] ( std :: string story_id , std :: vector < fuchsia :: modular :: Annotation > annotations ) { FX_NOTREACHED ( ) << " " << story_id << " " << story_name_no_update ; } ) ; bool updated { } ; storage -> add_on_annotations_updated_once ( story_name , [ & ] ( std :: string story_id , std :: vector < fuchsia :: modular :: Annotation > annotations ) { updated = true ; } ) ; std :: vector < fuchsia :: modular :: Annotation > annotations { } ; fuchsia :: modular :: AnnotationValue annotation_value ; annotation_value . set_text ( " " ) ; auto annotation = fuchsia :: modular :: Annotation { . key = " " , . value = fidl :: MakeOptional ( std :: move ( annotation_value ) ) } ; annotations . push_back ( fidl :: Clone ( annotation ) ) ; storage -> MergeStoryAnnotations ( story_name , std :: move ( annotations ) ) ; EXPECT_TRUE ( updated ) ; }
Verifies that an on_annotations_updated callback registered with a particular story_id
is invoked when only that story's annotations are updated.
Verifies that an on_annotations_updated callback registered with a particular story_id is invoked when only that story ' s annotations are updated .
// Create a story with no annotations. /*annotations=*/ // Annotate the story. // Only the callback for |story_name| should have been called.