• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 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_RECT_CHROMIUM_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_
7 
8 #include "base/logging.h"
9 
10 namespace mojo {
11 namespace test {
12 
13 // An implementation of a hypothetical Rect type specifically for consumers in
14 // in Chromium.
15 class RectChromium {
16  public:
RectChromium()17   RectChromium() {}
RectChromium(const RectChromium & other)18   RectChromium(const RectChromium& other)
19       : x_(other.x_),
20         y_(other.y_),
21         width_(other.width_),
22         height_(other.height_) {}
RectChromium(int x,int y,int width,int height)23   RectChromium(int x, int y, int width, int height) :
24       x_(x), y_(y), width_(width), height_(height) {
25     DCHECK_GE(width_, 0);
26     DCHECK_GE(height_, 0);
27   }
~RectChromium()28   ~RectChromium() {}
29 
30   RectChromium& operator=(const RectChromium& other) {
31     x_ = other.x_;
32     y_ = other.y_;
33     width_ = other.width_;
34     height_ = other.height_;
35     return *this;
36   }
37 
x()38   int x() const { return x_; }
set_x(int x)39   void set_x(int x) { x_ = x; }
40 
y()41   int y() const { return y_; }
set_y(int y)42   void set_y(int y) { y_ = y; }
43 
width()44   int width() const { return width_; }
set_width(int width)45   void set_width(int width) {
46     DCHECK_GE(width, 0);
47     width_ = width;
48   }
49 
height()50   int height() const { return height_; }
set_height(int height)51   void set_height(int height) {
52     DCHECK_GE(height, 0);
53     height_ = height;
54   }
55 
GetArea()56   int GetArea() const { return width_ * height_; }
57 
58  private:
59   int x_ = 0;
60   int y_ = 0;
61   int width_ = 0;
62   int height_ = 0;
63 };
64 
65 }  // namespace test
66 }  // namespace mojo
67 
68 #endif  // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_
69