File tree Expand file tree Collapse file tree 5 files changed +102
-0
lines changed
Expand file tree Collapse file tree 5 files changed +102
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ qt_add_qml_module(scratchcpp-render
5555 penlayerpainter.cpp
5656 penlayerpainter.h
5757 penattributes.h
58+ blocks/penextension.cpp
59+ blocks/penextension.h
5860 blocks/penblocks.cpp
5961 blocks/penblocks.h
6062)
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: LGPL-3.0-or-later
2+
3+ #include < scratchcpp/iengine.h>
4+
5+ #include " penextension.h"
6+ #include " penblocks.h"
7+
8+ using namespace scratchcpprender ;
9+ using namespace libscratchcpp ;
10+
11+ std::string PenExtension::name () const
12+ {
13+ return " pen" ;
14+ }
15+
16+ std::string PenExtension::description () const
17+ {
18+ return " Pen extension" ;
19+ }
20+
21+ void PenExtension::registerSections (IEngine *engine)
22+ {
23+ engine->registerSection (std::make_shared<PenBlocks>());
24+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: LGPL-3.0-or-later
2+
3+ #pragma once
4+
5+ #include < scratchcpp/iextension.h>
6+
7+ namespace scratchcpprender
8+ {
9+
10+ class PenExtension : public libscratchcpp ::IExtension
11+ {
12+ public:
13+ std::string name () const override ;
14+ std::string description () const override ;
15+
16+ void registerSections (libscratchcpp::IEngine *engine) override ;
17+ };
18+
19+ } // namespace scratchcpprender
Original file line number Diff line number Diff line change @@ -15,3 +15,21 @@ target_link_libraries(
1515
1616add_test (pen_blocks_test)
1717gtest_discover_tests(pen_blocks_test)
18+
19+ # penextension_test
20+ add_executable (
21+ penextension_test
22+ penextension_test.cpp
23+ )
24+
25+ target_link_libraries (
26+ penextension_test
27+ GTest::gtest_main
28+ GTest::gmock_main
29+ scratchcpp-render
30+ scratchcpprender_mocks
31+ ${QT_LIBS}
32+ )
33+
34+ add_test (penextension_test)
35+ gtest_discover_tests(penextension_test)
Original file line number Diff line number Diff line change 1+ #include < blocks/penextension.h>
2+ #include < blocks/penblocks.h>
3+ #include < enginemock.h>
4+
5+ #include " ../common.h"
6+
7+ using namespace scratchcpprender ;
8+ using namespace libscratchcpp ;
9+
10+ using ::testing::WithArgs;
11+ using ::testing::Invoke;
12+ using ::testing::_;
13+
14+ TEST (PenExtensionTest, Name)
15+ {
16+ PenExtension ext;
17+ ASSERT_EQ (ext.name (), " pen" );
18+ }
19+
20+ TEST (PenExtensionTest, Description)
21+ {
22+ PenExtension ext;
23+ ASSERT_EQ (ext.description (), " Pen extension" );
24+ }
25+
26+ TEST (PenExtensionTest, IncludeByDefault)
27+ {
28+ PenExtension ext;
29+ ASSERT_FALSE (ext.includeByDefault ());
30+ }
31+
32+ TEST (PenExtensionTest, RegisterSections)
33+ {
34+ PenExtension ext;
35+ EngineMock engine;
36+
37+ EXPECT_CALL (engine, registerSection (_)).WillOnce (WithArgs<0 >(Invoke ([](std::shared_ptr<IBlockSection> section) { ASSERT_TRUE (dynamic_cast <PenBlocks *>(section.get ())); })));
38+ ext.registerSections (&engine);
39+ }
You can’t perform that action at this time.
0 commit comments