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

Side by Side Diff: chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/sync_internals_message_handler.h" 5 #include "chrome/browser/ui/webui/sync_internals_message_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 16 matching lines...) Expand all
27 content::WebUI* web_ui, 27 content::WebUI* web_ui,
28 std::unique_ptr<AboutSyncDataExtractor> about_sync_data_extractor) 28 std::unique_ptr<AboutSyncDataExtractor> about_sync_data_extractor)
29 : SyncInternalsMessageHandler(std::move(about_sync_data_extractor)) { 29 : SyncInternalsMessageHandler(std::move(about_sync_data_extractor)) {
30 set_web_ui(web_ui); 30 set_web_ui(web_ui);
31 } 31 }
32 }; 32 };
33 33
34 class FakeExtractor : public AboutSyncDataExtractor { 34 class FakeExtractor : public AboutSyncDataExtractor {
35 public: 35 public:
36 std::unique_ptr<base::DictionaryValue> ConstructAboutInformation( 36 std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
37 syncer::SyncService* service, 37 sync_driver::SyncService* service,
38 SigninManagerBase* signin) override { 38 SigninManagerBase* signin) override {
39 call_count_++; 39 call_count_++;
40 last_service_ = service; 40 last_service_ = service;
41 last_signin_ = signin; 41 last_signin_ = signin;
42 std::unique_ptr<base::DictionaryValue> dictionary( 42 std::unique_ptr<base::DictionaryValue> dictionary(
43 new base::DictionaryValue()); 43 new base::DictionaryValue());
44 dictionary->SetString("fake_key", "fake_value"); 44 dictionary->SetString("fake_key", "fake_value");
45 return dictionary; 45 return dictionary;
46 } 46 }
47 47
48 int call_count() const { return call_count_; } 48 int call_count() const { return call_count_; }
49 syncer::SyncService* last_service() const { return last_service_; } 49 sync_driver::SyncService* last_service() const { return last_service_; }
50 SigninManagerBase* last_signin() const { return last_signin_; } 50 SigninManagerBase* last_signin() const { return last_signin_; }
51 51
52 private: 52 private:
53 int call_count_ = 0; 53 int call_count_ = 0;
54 syncer::SyncService* last_service_ = nullptr; 54 sync_driver::SyncService* last_service_ = nullptr;
55 SigninManagerBase* last_signin_ = nullptr; 55 SigninManagerBase* last_signin_ = nullptr;
56 }; 56 };
57 57
58 class SyncInternalsMessageHandlerTest : public ::testing::Test { 58 class SyncInternalsMessageHandlerTest : public ::testing::Test {
59 protected: 59 protected:
60 SyncInternalsMessageHandlerTest() { 60 SyncInternalsMessageHandlerTest() {
61 site_instance_ = content::SiteInstance::Create(&profile_); 61 site_instance_ = content::SiteInstance::Create(&profile_);
62 web_contents_.reset(content::WebContents::Create( 62 web_contents_.reset(content::WebContents::Create(
63 content::WebContents::CreateParams(&profile_, site_instance_.get()))); 63 content::WebContents::CreateParams(&profile_, site_instance_.get())));
64 web_ui_.set_web_contents(web_contents_.get()); 64 web_ui_.set_web_contents(web_contents_.get());
65 fake_extractor_ = new FakeExtractor(); 65 fake_extractor_ = new FakeExtractor();
66 handler_.reset(new TestableSyncInternalsMessageHandler( 66 handler_.reset(new TestableSyncInternalsMessageHandler(
67 &web_ui_, std::unique_ptr<FakeExtractor>(fake_extractor_))); 67 &web_ui_, std::unique_ptr<FakeExtractor>(fake_extractor_)));
68 } 68 }
69 69
70 void ValidateAboutInfoCall() { 70 void ValidateAboutInfoCall() {
71 const ScopedVector<content::TestWebUI::CallData>& data_vector = 71 const ScopedVector<content::TestWebUI::CallData>& data_vector =
72 web_ui_.call_data(); 72 web_ui_.call_data();
73 ASSERT_FALSE(data_vector.empty()); 73 ASSERT_FALSE(data_vector.empty());
74 EXPECT_EQ(1u, data_vector.size()); 74 EXPECT_EQ(1u, data_vector.size());
75 75
76 const content::TestWebUI::CallData& call_data = *data_vector[0]; 76 const content::TestWebUI::CallData& call_data = *data_vector[0];
77 77
78 EXPECT_EQ(syncer::sync_ui_util::kDispatchEvent, call_data.function_name()); 78 EXPECT_EQ(sync_driver::sync_ui_util::kDispatchEvent,
79 call_data.function_name());
79 80
80 const base::Value* arg1 = call_data.arg1(); 81 const base::Value* arg1 = call_data.arg1();
81 ASSERT_TRUE(arg1); 82 ASSERT_TRUE(arg1);
82 std::string event_type; 83 std::string event_type;
83 EXPECT_TRUE(arg1->GetAsString(&event_type)); 84 EXPECT_TRUE(arg1->GetAsString(&event_type));
84 EXPECT_EQ(syncer::sync_ui_util::kOnAboutInfoUpdated, event_type); 85 EXPECT_EQ(sync_driver::sync_ui_util::kOnAboutInfoUpdated, event_type);
85 86
86 const base::Value* arg2 = call_data.arg2(); 87 const base::Value* arg2 = call_data.arg2();
87 ASSERT_TRUE(arg2); 88 ASSERT_TRUE(arg2);
88 89
89 const base::DictionaryValue* root_dictionary = nullptr; 90 const base::DictionaryValue* root_dictionary = nullptr;
90 ASSERT_TRUE(arg2->GetAsDictionary(&root_dictionary)); 91 ASSERT_TRUE(arg2->GetAsDictionary(&root_dictionary));
91 92
92 std::string fake_value; 93 std::string fake_value;
93 EXPECT_TRUE(root_dictionary->GetString("fake_key", &fake_value)); 94 EXPECT_TRUE(root_dictionary->GetString("fake_key", &fake_value));
94 EXPECT_EQ("fake_value", fake_value); 95 EXPECT_EQ("fake_value", fake_value);
(...skipping 26 matching lines...) Expand all
121 } 122 }
122 123
123 TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoWithoutService) { 124 TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoWithoutService) {
124 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync); 125 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync);
125 handler()->OnStateChanged(); 126 handler()->OnStateChanged();
126 EXPECT_EQ(1, fake_extractor()->call_count()); 127 EXPECT_EQ(1, fake_extractor()->call_count());
127 EXPECT_EQ(nullptr, fake_extractor()->last_service()); 128 EXPECT_EQ(nullptr, fake_extractor()->last_service());
128 EXPECT_EQ(nullptr, fake_extractor()->last_signin()); 129 EXPECT_EQ(nullptr, fake_extractor()->last_signin());
129 ValidateAboutInfoCall(); 130 ValidateAboutInfoCall();
130 } 131 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_message_handler.cc ('k') | chrome/browser/ui/webui/sync_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698