Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df13934f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "libui: PrintTo and comparisons for values for tests"

parents c718b0d3 ea629288
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -280,6 +280,20 @@ bool Region::isTriviallyEqual(const Region& region) const {
    return begin() == region.begin();
    return begin() == region.begin();
}
}


bool Region::hasSameRects(const Region& other) const {
    size_t thisRectCount = 0;
    android::Rect const* thisRects = getArray(&thisRectCount);
    size_t otherRectCount = 0;
    android::Rect const* otherRects = other.getArray(&otherRectCount);

    if (thisRectCount != otherRectCount) return false;

    for (size_t i = 0; i < thisRectCount; i++) {
        if (thisRects[i] != otherRects[i]) return false;
    }
    return true;
}

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


void Region::addRectUnchecked(int l, int t, int r, int b)
void Region::addRectUnchecked(int l, int t, int r, int b)
+9 −0
Original line number Original line Diff line number Diff line
@@ -49,6 +49,15 @@ bool Transform::absIsOne(float f) {
    return isZero(fabs(f) - 1.0f);
    return isZero(fabs(f) - 1.0f);
}
}


bool Transform::operator==(const Transform& other) const {
    return mMatrix[0][0] == other.mMatrix[0][0] && mMatrix[0][1] == other.mMatrix[0][1] &&
            mMatrix[0][2] == other.mMatrix[0][2] && mMatrix[1][0] == other.mMatrix[1][0] &&
            mMatrix[1][1] == other.mMatrix[1][1] && mMatrix[1][2] == other.mMatrix[1][2] &&
            mMatrix[2][0] == other.mMatrix[2][0] && mMatrix[2][1] == other.mMatrix[2][1] &&
            mMatrix[2][2] == other.mMatrix[2][2];
    ;
}

Transform Transform::operator * (const Transform& rhs) const
Transform Transform::operator * (const Transform& rhs) const
{
{
    if (CC_LIKELY(mType == IDENTITY))
    if (CC_LIKELY(mType == IDENTITY))
+7 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


#pragma once
#pragma once


#include <ostream>

namespace android {
namespace android {


class FloatRect {
class FloatRect {
@@ -52,4 +54,9 @@ inline bool operator==(const FloatRect& a, const FloatRect& b) {
    return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom;
    return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom;
}
}


static inline void PrintTo(const FloatRect& rect, ::std::ostream* os) {
    *os << "FloatRect(" << rect.left << ", " << rect.top << ", " << rect.right << ", "
        << rect.bottom << ")";
}

}  // namespace android
}  // namespace android
+8 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_UI_RECT
#ifndef ANDROID_UI_RECT
#define ANDROID_UI_RECT
#define ANDROID_UI_RECT


#include <ostream>

#include <utils/Flattenable.h>
#include <utils/Flattenable.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/TypeHelpers.h>
#include <utils/TypeHelpers.h>
@@ -214,6 +216,12 @@ public:
    }
    }
};
};


// Defining PrintTo helps with Google Tests.
static inline void PrintTo(const Rect& rect, ::std::ostream* os) {
    *os << "Rect(" << rect.left << ", " << rect.top << ", " << rect.right << ", " << rect.bottom
        << ")";
}

ANDROID_BASIC_TYPES_TRAITS(Rect)
ANDROID_BASIC_TYPES_TRAITS(Rect)


}; // namespace android
}; // namespace android
+18 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@


#include <stdint.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/types.h>
#include <ostream>


#include <utils/Vector.h>
#include <utils/Vector.h>


@@ -119,6 +120,8 @@ public:
    // returns true if the regions share the same underlying storage
    // returns true if the regions share the same underlying storage
    bool isTriviallyEqual(const Region& region) const;
    bool isTriviallyEqual(const Region& region) const;


    // returns true if the regions consist of the same rectangle sequence
    bool hasSameRects(const Region& region) const;


    /* various ways to access the rectangle list */
    /* various ways to access the rectangle list */


@@ -213,6 +216,21 @@ Region& Region::operator -= (const Region& rhs) {
Region& Region::operator += (const Point& pt) {
Region& Region::operator += (const Point& pt) {
    return translateSelf(pt.x, pt.y);
    return translateSelf(pt.x, pt.y);
}
}

// Defining PrintTo helps with Google Tests.
static inline void PrintTo(const Region& region, ::std::ostream* os) {
    Region::const_iterator head = region.begin();
    Region::const_iterator const tail = region.end();
    bool first = true;
    while (head != tail) {
        *os << (first ? "Region(" : ", ");
        PrintTo(*head, os);
        head++;
        first = false;
    }
    *os << ")";
}

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
}; // namespace android
}; // namespace android


Loading