src/net/reporting/reporting_delivery_agent_unittest.cc
TEST_F(ReportingDeliveryAgentTest, ParallelizeUploadsAcrossGroups) {
  static const GURL kDifferentEndpoint("https://endpoint2/");
  static const std::string kDifferentGroup("group2");
  const ReportingEndpointGroupKey kDifferentGroupKey(kNik_, kOrigin_,
                                                     kDifferentGroup);

  ASSERT_TRUE(SetEndpointInCache(kGroupKey_, kEndpoint_, kExpires_));
  ASSERT_TRUE(
      SetEndpointInCache(kDifferentGroupKey, kDifferentEndpoint, kExpires_));

  // Trigger and complete an upload to start the delivery timer.
  UploadFirstReportAndStartTimer();

  AddReport(kNik_, kUrl_, kGroup_);
  AddReport(kNik_, kUrl_, kDifferentGroup);

  EXPECT_TRUE(delivery_timer()->IsRunning());
  delivery_timer()->Fire();
  ASSERT_EQ(2u, pending_uploads().size());

  pending_uploads()[1]->Complete(ReportingUploader::Outcome::SUCCESS);
  pending_uploads()[0]->Complete(ReportingUploader::Outcome::SUCCESS);
  EXPECT_EQ(0u, pending_uploads().size());

  {
    ReportingEndpoint::Statistics stats =
        GetEndpointStatistics(kGroupKey_, kEndpoint_);
    EXPECT_EQ(1, stats.attempted_uploads);
    EXPECT_EQ(1, stats.successful_uploads);
    EXPECT_EQ(1, stats.attempted_reports);
    EXPECT_EQ(1, stats.successful_reports);
  }
  {
    ReportingEndpoint::Statistics stats =
        GetEndpointStatistics(kDifferentGroupKey, kDifferentEndpoint);
    EXPECT_EQ(1, stats.attempted_uploads);
    EXPECT_EQ(1, stats.successful_uploads);
    EXPECT_EQ(1, stats.attempted_reports);
    EXPECT_EQ(1, stats.successful_reports);
  }
}
// Tests that the agent will start parallel uploads to different groups within
// the same (NIK, origin) to endpoints with different URLs.
Tests that the agent will start parallel uploads to different groups within
the same (NIK, origin) to endpoints with different URLs.
Tests that the agent will start parallel uploads to different groups within the same ( NIK origin ) to endpoints with different URLs .
TEST_F(ReportingDeliveryAgentTest, ParallelizeUploadsAcrossGroups) {
  static const GURL kDifferentEndpoint("https://endpoint2/");
  static const std::string kDifferentGroup("group2");
  const ReportingEndpointGroupKey kDifferentGroupKey(kNik_, kOrigin_,
                                                     kDifferentGroup);
  ASSERT_TRUE(SetEndpointInCache(kGroupKey_, kEndpoint_, kExpires_));
  ASSERT_TRUE(
      SetEndpointInCache(kDifferentGroupKey, kDifferentEndpoint, kExpires_));
  UploadFirstReportAndStartTimer();
  AddReport(kNik_, kUrl_, kGroup_);
  AddReport(kNik_, kUrl_, kDifferentGroup);
  EXPECT_TRUE(delivery_timer()->IsRunning());
  delivery_timer()->Fire();
  ASSERT_EQ(2u, pending_uploads().size());
  pending_uploads()[1]->Complete(ReportingUploader::Outcome::SUCCESS);
  pending_uploads()[0]->Complete(ReportingUploader::Outcome::SUCCESS);
  EXPECT_EQ(0u, pending_uploads().size());
  {
    ReportingEndpoint::Statistics stats =
        GetEndpointStatistics(kGroupKey_, kEndpoint_);
    EXPECT_EQ(1, stats.attempted_uploads);
    EXPECT_EQ(1, stats.successful_uploads);
    EXPECT_EQ(1, stats.attempted_reports);
    EXPECT_EQ(1, stats.successful_reports);
  }
  {
    ReportingEndpoint::Statistics stats =
        GetEndpointStatistics(kDifferentGroupKey, kDifferentEndpoint);
    EXPECT_EQ(1, stats.attempted_uploads);
    EXPECT_EQ(1, stats.successful_uploads);
    EXPECT_EQ(1, stats.attempted_reports);
    EXPECT_EQ(1, stats.successful_reports);
  }
}
TEST_F ( ReportingDeliveryAgentTest , ParallelizeUploadsAcrossGroups ) { static const GURL kDifferentEndpoint ( " " ) ; static const std :: string kDifferentGroup ( " " ) ; const ReportingEndpointGroupKey kDifferentGroupKey ( kNik_ , kOrigin_ , kDifferentGroup ) ; ASSERT_TRUE ( SetEndpointInCache ( kGroupKey_ , kEndpoint_ , kExpires_ ) ) ; ASSERT_TRUE ( SetEndpointInCache ( kDifferentGroupKey , kDifferentEndpoint , kExpires_ ) ) ; UploadFirstReportAndStartTimer ( ) ; AddReport ( kNik_ , kUrl_ , kGroup_ ) ; AddReport ( kNik_ , kUrl_ , kDifferentGroup ) ; EXPECT_TRUE ( delivery_timer ( ) -> IsRunning ( ) ) ; delivery_timer ( ) -> Fire ( ) ; ASSERT_EQ ( 2u , pending_uploads ( ) . size ( ) ) ; pending_uploads ( ) [ 1 ] -> Complete ( ReportingUploader :: Outcome :: SUCCESS ) ; pending_uploads ( ) [ 0 ] -> Complete ( ReportingUploader :: Outcome :: SUCCESS ) ; EXPECT_EQ ( 0u , pending_uploads ( ) . size ( ) ) ; { ReportingEndpoint :: Statistics stats = GetEndpointStatistics ( kGroupKey_ , kEndpoint_ ) ; EXPECT_EQ ( 1 , stats . attempted_uploads ) ; EXPECT_EQ ( 1 , stats . successful_uploads ) ; EXPECT_EQ ( 1 , stats . attempted_reports ) ; EXPECT_EQ ( 1 , stats . successful_reports ) ; } { ReportingEndpoint :: Statistics stats = GetEndpointStatistics ( kDifferentGroupKey , kDifferentEndpoint ) ; EXPECT_EQ ( 1 , stats . attempted_uploads ) ; EXPECT_EQ ( 1 , stats . successful_uploads ) ; EXPECT_EQ ( 1 , stats . attempted_reports ) ; EXPECT_EQ ( 1 , stats . successful_reports ) ; } }
Tests that the agent will start parallel uploads to different groups within
the same (NIK, origin) to endpoints with different URLs.
Tests that the agent will start parallel uploads to different groups within the same ( NIK origin ) to endpoints with different URLs .
// Trigger and complete an upload to start the delivery timer.