1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <gtest/gtest.h>
18 
19 #include "OpDumper.h"
20 #include "tests/common/TestUtils.h"
21 
22 using namespace android;
23 using namespace android::uirenderer;
24 
TEST(OpDumper,dump)25 TEST(OpDumper, dump) {
26     SkPaint paint;
27     RectOp op(uirenderer::Rect(100, 100), Matrix4::identity(), nullptr, &paint);
28 
29     std::stringstream stream;
30     OpDumper::dump(op, stream);
31     EXPECT_STREQ("RectOp [100 x 100]", stream.str().c_str());
32 
33     stream.str("");
34     OpDumper::dump(op, stream, 2);
35     EXPECT_STREQ("    RectOp [100 x 100]", stream.str().c_str());
36 
37     ClipRect clipRect(uirenderer::Rect(50, 50));
38     op.localClip = &clipRect;
39 
40     stream.str("");
41     OpDumper::dump(op, stream, 2);
42     EXPECT_STREQ("    RectOp [100 x 100] clip=[50 x 50] mode=0", stream.str().c_str());
43 }
44