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

Side by Side Diff: mojo/common/common_custom_types_unittest.cc

Issue 2626093004: EnumTraits for base::i18n::TextDirection. (Closed)
Patch Set: Addressed feedback. Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/numerics/safe_math.h" 9 #include "base/numerics/safe_math.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 // TestFile implementation: 164 // TestFile implementation:
165 void BounceFile(base::File in, const BounceFileCallback& callback) override { 165 void BounceFile(base::File in, const BounceFileCallback& callback) override {
166 callback.Run(std::move(in)); 166 callback.Run(std::move(in));
167 } 167 }
168 168
169 private: 169 private:
170 mojo::Binding<TestFile> binding_; 170 mojo::Binding<TestFile> binding_;
171 }; 171 };
172 172
173 class TestTextDirectionImpl : public TestTextDirection {
174 public:
175 explicit TestTextDirectionImpl(TestTextDirectionRequest request)
176 : binding_(this, std::move(request)) {}
177
178 // TestTextDirection:
179 void BounceTextDirection(
180 base::i18n::TextDirection in,
181 const BounceTextDirectionCallback& callback) override {
182 callback.Run(in);
183 }
184
185 private:
186 mojo::Binding<TestTextDirection> binding_;
187 };
188
173 class CommonCustomTypesTest : public testing::Test { 189 class CommonCustomTypesTest : public testing::Test {
174 protected: 190 protected:
175 CommonCustomTypesTest() {} 191 CommonCustomTypesTest() {}
176 ~CommonCustomTypesTest() override {} 192 ~CommonCustomTypesTest() override {}
177 193
178 private: 194 private:
179 base::MessageLoop message_loop_; 195 base::MessageLoop message_loop_;
180 196
181 DISALLOW_COPY_AND_ASSIGN(CommonCustomTypesTest); 197 DISALLOW_COPY_AND_ASSIGN(CommonCustomTypesTest);
182 }; 198 };
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 405 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
390 // Test that |file_out| is set to an invalid file. 406 // Test that |file_out| is set to an invalid file.
391 base::File file_out( 407 base::File file_out(
392 temp_dir.GetPath().AppendASCII("test_file.txt"), 408 temp_dir.GetPath().AppendASCII("test_file.txt"),
393 base::File::FLAG_CREATE | base::File::FLAG_WRITE | base::File::FLAG_READ); 409 base::File::FLAG_CREATE | base::File::FLAG_WRITE | base::File::FLAG_READ);
394 410
395 ASSERT_TRUE(ptr->BounceFile(base::File(), &file_out)); 411 ASSERT_TRUE(ptr->BounceFile(base::File(), &file_out));
396 EXPECT_FALSE(file_out.IsValid()); 412 EXPECT_FALSE(file_out.IsValid());
397 } 413 }
398 414
415 TEST_F(CommonCustomTypesTest, TextDirection) {
416 base::i18n::TextDirection kTestDirections[] = {base::i18n::LEFT_TO_RIGHT,
417 base::i18n::RIGHT_TO_LEFT,
418 base::i18n::UNKNOWN_DIRECTION};
419
420 TestTextDirectionPtr ptr;
421 TestTextDirectionImpl impl(MakeRequest(&ptr));
422
423 for (size_t i = 0; i < arraysize(kTestDirections); i++) {
424 base::i18n::TextDirection direction_out;
425 ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out));
426 EXPECT_EQ(kTestDirections[i], direction_out);
427 }
428 }
429
399 } // namespace test 430 } // namespace test
400 } // namespace common 431 } // namespace common
401 } // namespace mojo 432 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/common_custom_types_struct_traits.cc ('k') | mojo/common/test_common_custom_types.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698