Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3377)

Unified Diff: chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc

Issue 2872023002: [Sync] Add a simple UI to sync-internals to create UserEvents. (Closed)
Patch Set: Fixed unittests. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc b/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
index 466b6e2fb3b21cf5c9468ae4890ca4b714b86de3..dd6b6405bafa8c4ea5f6db16e10909941ee96711 100644
--- a/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
+++ b/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
@@ -29,6 +29,8 @@ class TestableSyncInternalsMessageHandler : public SyncInternalsMessageHandler {
: SyncInternalsMessageHandler(std::move(about_sync_data_extractor)) {
set_web_ui(web_ui);
}
+
+ void SignalIsInitialized() { AllowJavascript(); }
};
class FakeExtractor : public AboutSyncDataExtractor {
@@ -93,7 +95,11 @@ class SyncInternalsMessageHandlerTest : public ::testing::Test {
EXPECT_EQ("fake_value", fake_value);
}
- SyncInternalsMessageHandler* handler() { return handler_.get(); }
+ void ValidateEmptyAboutInfoCall() {
+ EXPECT_TRUE(web_ui_.call_data().empty());
+ }
+
+ TestableSyncInternalsMessageHandler* handler() { return handler_.get(); }
FakeExtractor* fake_extractor() { return fake_extractor_; }
private:
@@ -102,7 +108,7 @@ class SyncInternalsMessageHandlerTest : public ::testing::Test {
content::TestWebUI web_ui_;
scoped_refptr<content::SiteInstance> site_instance_;
std::unique_ptr<content::WebContents> web_contents_;
- std::unique_ptr<SyncInternalsMessageHandler> handler_;
+ std::unique_ptr<TestableSyncInternalsMessageHandler> handler_;
// Non-owning pointer to the about information the handler uses. This
// extractor is owned by the handler.
@@ -111,7 +117,13 @@ class SyncInternalsMessageHandlerTest : public ::testing::Test {
} // namespace
+TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoBeforeInitialized) {
+ handler()->OnStateChanged(nullptr);
+ ValidateEmptyAboutInfoCall();
+}
+
TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoWithService) {
+ handler()->SignalIsInitialized();
handler()->OnStateChanged(nullptr);
EXPECT_EQ(1, fake_extractor()->call_count());
EXPECT_NE(nullptr, fake_extractor()->last_service());
@@ -121,6 +133,7 @@ TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoWithService) {
TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoWithoutService) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync);
+ handler()->SignalIsInitialized();
handler()->OnStateChanged(nullptr);
EXPECT_EQ(1, fake_extractor()->call_count());
EXPECT_EQ(nullptr, fake_extractor()->last_service());

Powered by Google App Engine
This is Rietveld 408576698