src/modular/bin/sessionmgr/storage/session_storage_unittest.cc
// Verifies that multiple on_annotations_updated for a single story callbacks are called
// when annotations are added/merged.
Verifies that multiple on_annotations_updated for a single story callbacks are called
when annotations are added/merged.
Verifies that multiple on_annotations_updated for a single story callbacks are called when annotations are added / merged .
TEST_F(SessionStorageTest, OnAnnotationsUpdatedMultipleCallbacks) {
  static constexpr auto story_name = "story";
  static constexpr auto num_callbacks = 5;
  auto storage = CreateStorage();
  storage->CreateStory(story_name, {});
  auto updated_count = 0;
  auto callback = [&](std::string story_id, std::vector<fuchsia::modular::Annotation> annotations) {
    updated_count++;
  };
  for (int i = 0; i < num_callbacks; i++) {
    storage->add_on_annotations_updated_once(story_name, callback);
  }
  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_EQ(num_callbacks, updated_count);
}
TEST_F ( SessionStorageTest , OnAnnotationsUpdatedMultipleCallbacks ) { static constexpr auto story_name = " " ; static constexpr auto num_callbacks = 5 ; auto storage = CreateStorage ( ) ; storage -> CreateStory ( story_name , { } ) ; auto updated_count = 0 ; auto callback = [ & ] ( std :: string story_id , std :: vector < fuchsia :: modular :: Annotation > annotations ) { updated_count ++ ; } ; for ( int i = 0 ; i < num_callbacks ; i ++ ) { storage -> add_on_annotations_updated_once ( story_name , callback ) ; } 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_EQ ( num_callbacks , updated_count ) ; }
Verifies that multiple on_annotations_updated for a single story callbacks are called
when annotations are added/merged.
Verifies that multiple on_annotations_updated for a single story callbacks are called when annotations are added / merged .
// Create a story with no annotations. /*annotations=*/ // Annotate the story.