class FakeCobaltService

Defined at line 38 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

A fake for the CobaltService, to use in testing where logged events should not be sent.

This class uses the FakeLogger to return loggers from NewLogger.

Example:

FakeCobaltService fake_service;

// Get a logger and log an Event:

auto logger = fake_service.NewLogger(project_context);

logger.LogEvent(Event);

// Verify the logger calls:

EXPECT_EQ(fake_service_->last_logger_created()->call_count(), 1);

Public Methods

std::unique_ptr<logger::LoggerInterface> NewLogger (std::unique_ptr<logger::ProjectContext> project_context)

Returns a new instance of a FakeLogger object for use in testing.

Defined at line 41 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

std::unique_ptr<logger::LoggerInterface> NewLogger (uint32_t customer_id, uint32_t project_id)

Defined at line 46 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

std::unique_ptr<logger::LoggerInterface> NewLogger (uint32_t customer_id, uint32_t project_id, std::vector<uint32_t> experiment_ids)

Defined at line 57 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void SystemClockIsAccurate (std::unique_ptr<util::SystemClockInterface> system_clock, bool start_event_aggregator_worker)

Records the accuracy of the system clock for testing.

Defined at line 63 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void FailNextNewLogger ()

Defined at line 68 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void SetDataCollectionPolicy (DataCollectionPolicy policy)

Records the data collection policy for testing.

Defined at line 71 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

system_data::SystemDataInterface * system_data ()

Defined at line 75 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

system_data::SystemDataInterface & system_data_ref ()

Defined at line 76 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

Status GenerateAggregatedObservations (uint32_t final_day_index_utc)

The remaining methods from the CobaltServiceInterface are not used in testing with this fake,

so they are mostly unimplemented.

Defined at line 83 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

Status GenerateAggregatedObservations ()

Defined at line 87 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

uint64_t num_observations_added ()

Defined at line 89 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

std::vector<uint64_t> num_observations_added_for_reports (const std::vector<lib::ReportIdentifier> & report_specs)

Defined at line 91 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void ShippingRequestSendSoon (const SendCallback & send_callback)

Defined at line 96 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void WaitUntilShippingIdle (std::chrono::seconds max_wait)

Defined at line 101 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void ShutDown ()

Defined at line 103 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

size_t num_shipping_send_attempts ()

Defined at line 105 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

size_t num_shipping_failed_attempts ()

Defined at line 106 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

DataCollectionPolicy data_collection_policy ()

Remaining public methods are for determining the current state of the fake.

Defined at line 112 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

cobalt::logger::testing::FakeLogger * last_logger_created ()

Defined at line 114 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

bool system_clock_is_accurate ()

Defined at line 116 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

bool is_shut_down ()

Defined at line 118 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void set_observation_error_code (StatusCode code)

Defined at line 120 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h

void set_send_soon_succeeds (bool success)

Defined at line 122 of file ../../third_party/cobalt/src/public/testing/fake_cobalt_service.h