OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 "chrome/browser/sync/syncable/model_type_test_util.h" | |
6 | |
7 namespace syncable { | |
8 | |
9 void PrintTo(ModelTypeSet model_types, ::std::ostream* os) { | |
10 *os << ModelTypeSetToString(model_types); | |
11 } | |
12 | |
13 namespace { | |
14 | |
15 // Matcher implementation for HasModelTypes(). | |
16 class HasModelTypesMatcher | |
17 : public ::testing::MatcherInterface<ModelTypeSet> { | |
18 public: | |
19 explicit HasModelTypesMatcher(ModelTypeSet expected_types) | |
20 : expected_types_(expected_types) {} | |
21 | |
22 virtual ~HasModelTypesMatcher() {} | |
23 | |
24 virtual bool MatchAndExplain( | |
25 ModelTypeSet model_types, | |
26 ::testing::MatchResultListener* listener) const { | |
27 // No need to annotate listener since we already define PrintTo(). | |
28 return model_types.Equals(expected_types_); | |
29 } | |
30 | |
31 virtual void DescribeTo(::std::ostream* os) const { | |
32 *os << "has model types " << ModelTypeSetToString(expected_types_); | |
33 } | |
34 | |
35 virtual void DescribeNegationTo(::std::ostream* os) const { | |
36 *os << "doesn't have model types " | |
37 << ModelTypeSetToString(expected_types_); | |
38 } | |
39 | |
40 private: | |
41 const ModelTypeSet expected_types_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(HasModelTypesMatcher); | |
44 }; | |
45 | |
46 } // namespace | |
47 | |
48 ::testing::Matcher<ModelTypeSet> HasModelTypes(ModelTypeSet expected_types) { | |
49 return ::testing::MakeMatcher(new HasModelTypesMatcher(expected_types)); | |
50 } | |
51 | |
52 } // namespace syncable | |
OLD | NEW |