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

Side by Side Diff: mojo/services/clipboard/clipboard_standalone_unittest.cc

Issue 611633002: mojom: Add associative arrays to the mojom language. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "mojo/common/common_type_converters.h" 7 #include "mojo/common/common_type_converters.h"
8 #include "mojo/services/public/interfaces/clipboard/clipboard.mojom.h" 8 #include "mojo/services/public/interfaces/clipboard/clipboard.mojom.h"
9 #include "mojo/shell/shell_test_helper.h" 9 #include "mojo/shell/shell_test_helper.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 16 matching lines...) Expand all
27 run_loop->Quit(); 27 run_loop->Quit();
28 } 28 }
29 29
30 void CopyVectorStringAndEndRunloop(std::vector<std::string>* output, 30 void CopyVectorStringAndEndRunloop(std::vector<std::string>* output,
31 base::RunLoop* run_loop, 31 base::RunLoop* run_loop,
32 const mojo::Array<mojo::String>& input) { 32 const mojo::Array<mojo::String>& input) {
33 *output = input.To<std::vector<std::string> >(); 33 *output = input.To<std::vector<std::string> >();
34 run_loop->Quit(); 34 run_loop->Quit();
35 } 35 }
36 36
37 void EchoData(base::RunLoop* run_loop,
38 const mojo::Map<mojo::String, mojo::String>& input) {
39 LOG(ERROR) << "We have " << input.size() << "fields";
40 std::map<std::string, std::string> m =
41 input.To<std::map<std::string, std::string>>();
42
43 for (auto& p : m)
44 LOG(ERROR) << "m[" << p.first << "] = " << p.second;
45
46 run_loop->Quit();
47 }
48
37 const char* kUninitialized = "Uninitialized data"; 49 const char* kUninitialized = "Uninitialized data";
38 const char* kPlainTextData = "Some plain data"; 50 const char* kPlainTextData = "Some plain data";
39 const char* kHtmlData = "<html>data</html>"; 51 const char* kHtmlData = "<html>data</html>";
40 52
41 } // namespace 53 } // namespace
42 54
43 namespace mojo { 55 namespace mojo {
44 namespace service { 56 namespace service {
45 57
46 class ClipboardStandaloneTest : public testing::Test { 58 class ClipboardStandaloneTest : public testing::Test {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_EQ(kPlainTextData, data); 186 EXPECT_EQ(kPlainTextData, data);
175 187
176 Array<MimeTypePairPtr> mime_data(0); 188 Array<MimeTypePairPtr> mime_data(0);
177 clipboard_->WriteClipboardData(mojo::Clipboard::TYPE_COPY_PASTE, 189 clipboard_->WriteClipboardData(mojo::Clipboard::TYPE_COPY_PASTE,
178 mime_data.Pass()); 190 mime_data.Pass());
179 191
180 EXPECT_EQ(2ul, GetSequenceNumber()); 192 EXPECT_EQ(2ul, GetSequenceNumber());
181 EXPECT_FALSE(GetDataOfType(mojo::Clipboard::MIME_TYPE_TEXT, &data)); 193 EXPECT_FALSE(GetDataOfType(mojo::Clipboard::MIME_TYPE_TEXT, &data));
182 } 194 }
183 195
196 TEST_F(ClipboardStandaloneTest, GetFakeMethodResult) {
197 base::RunLoop run_loop;
198 clipboard_->FakeTestMethod(
199 base::Bind(&EchoData, &run_loop));
200 run_loop.Run();
201 }
202
184 } // namespace service 203 } // namespace service
185 } // namespace mojo 204 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698