OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/macros.h" | |
6 #include "sync/internal_api/public/base/model_type_test_util.h" | |
7 | |
8 namespace syncer { | |
9 | |
10 void PrintTo(ModelTypeSet model_types, ::std::ostream* os) { | |
11 *os << ModelTypeSetToString(model_types); | |
12 } | |
13 | |
14 namespace { | |
15 | |
16 // Matcher implementation for HasModelTypes(). | |
17 class HasModelTypesMatcher | |
18 : public ::testing::MatcherInterface<ModelTypeSet> { | |
19 public: | |
20 explicit HasModelTypesMatcher(ModelTypeSet expected_types) | |
21 : expected_types_(expected_types) {} | |
22 | |
23 virtual ~HasModelTypesMatcher() {} | |
24 | |
25 virtual bool MatchAndExplain( | |
26 ModelTypeSet model_types, | |
27 ::testing::MatchResultListener* listener) const { | |
28 // No need to annotate listener since we already define PrintTo(). | |
29 return model_types == expected_types_; | |
30 } | |
31 | |
32 virtual void DescribeTo(::std::ostream* os) const { | |
33 *os << "has model types " << ModelTypeSetToString(expected_types_); | |
34 } | |
35 | |
36 virtual void DescribeNegationTo(::std::ostream* os) const { | |
37 *os << "doesn't have model types " | |
38 << ModelTypeSetToString(expected_types_); | |
39 } | |
40 | |
41 private: | |
42 const ModelTypeSet expected_types_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(HasModelTypesMatcher); | |
45 }; | |
46 | |
47 } // namespace | |
48 | |
49 ::testing::Matcher<ModelTypeSet> HasModelTypes(ModelTypeSet expected_types) { | |
50 return ::testing::MakeMatcher(new HasModelTypesMatcher(expected_types)); | |
51 } | |
52 | |
53 } // namespace syncer | |
OLD | NEW |