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 "sync/internal_api/public/base/model_type_test_util.h" 6 7 namespace syncer { 8 PrintTo(ModelTypeSet model_types,::std::ostream * os)9void 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: HasModelTypesMatcher(ModelTypeSet expected_types)19 explicit HasModelTypesMatcher(ModelTypeSet expected_types) 20 : expected_types_(expected_types) {} 21 ~HasModelTypesMatcher()22 virtual ~HasModelTypesMatcher() {} 23 MatchAndExplain(ModelTypeSet model_types,::testing::MatchResultListener * listener) const24 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 DescribeTo(::std::ostream * os) const31 virtual void DescribeTo(::std::ostream* os) const { 32 *os << "has model types " << ModelTypeSetToString(expected_types_); 33 } 34 DescribeNegationTo(::std::ostream * os) const35 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 HasModelTypes(ModelTypeSet expected_types)48::testing::Matcher<ModelTypeSet> HasModelTypes(ModelTypeSet expected_types) { 49 return ::testing::MakeMatcher(new HasModelTypesMatcher(expected_types)); 50 } 51 52 } // namespace syncer 53