Home | History | Annotate | Download | only in tests
      1 // Copyright 2014 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_
      6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_
      7 
      8 #include <stddef.h>
      9 
     10 #include "base/macros.h"
     11 
     12 namespace mojo {
     13 
     14 class CopyableType {
     15  public:
     16   CopyableType();
     17   CopyableType(const CopyableType& other);
     18   CopyableType& operator=(const CopyableType& other);
     19   ~CopyableType();
     20 
     21   bool copied() const { return copied_; }
     22   static size_t num_instances() { return num_instances_; }
     23   CopyableType* ptr() const { return ptr_; }
     24   void ResetCopied() { copied_ = false; }
     25 
     26  private:
     27   bool copied_;
     28   static size_t num_instances_;
     29   CopyableType* ptr_;
     30 };
     31 
     32 class MoveOnlyType {
     33  public:
     34   typedef MoveOnlyType Data_;
     35   MoveOnlyType();
     36   MoveOnlyType(MoveOnlyType&& other);
     37   MoveOnlyType& operator=(MoveOnlyType&& other);
     38   ~MoveOnlyType();
     39 
     40   bool moved() const { return moved_; }
     41   static size_t num_instances() { return num_instances_; }
     42   MoveOnlyType* ptr() const { return ptr_; }
     43   void ResetMoved() { moved_ = false; }
     44 
     45  private:
     46   bool moved_;
     47   static size_t num_instances_;
     48   MoveOnlyType* ptr_;
     49 
     50   DISALLOW_COPY_AND_ASSIGN(MoveOnlyType);
     51 };
     52 
     53 }  // namespace mojo
     54 
     55 #endif  // MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_
     56