@@ -1842,3 +1842,125 @@ TEST_F(LooksBlocksTest, GoForwardBackwardLayers_MoveStageBackward)
18421842 builder.run ();
18431843 ASSERT_EQ (stage->layerOrder (), 0 );
18441844}
1845+
1846+ TEST_F (LooksBlocksTest, BackdropNumberName_SpriteBackdropNumber)
1847+ {
1848+ auto sprite = std::make_shared<Sprite>();
1849+
1850+ auto stage = std::make_shared<Stage>();
1851+ auto backdrop1 = std::make_shared<Costume>(" backdrop1" , " a" , " png" );
1852+ auto backdrop2 = std::make_shared<Costume>(" backdrop2" , " b" , " png" );
1853+ auto testBackdrop = std::make_shared<Costume>(" test" , " c" , " svg" );
1854+ stage->addCostume (backdrop1);
1855+ stage->addCostume (backdrop2);
1856+ stage->addCostume (testBackdrop);
1857+
1858+ m_engine->setTargets ({ stage, sprite });
1859+ ScriptBuilder builder (m_extension.get (), m_engine, sprite);
1860+
1861+ builder.addBlock (" looks_backdropnumbername" );
1862+ builder.addDropdownField (" NUMBER_NAME" , " number" );
1863+ builder.captureBlockReturnValue ();
1864+ builder.build ();
1865+
1866+ stage->setCostumeIndex (2 );
1867+ builder.run ();
1868+
1869+ stage->setCostumeIndex (0 );
1870+ builder.run ();
1871+
1872+ List *list = builder.capturedValues ();
1873+ ASSERT_EQ (list->size (), 2 );
1874+ ASSERT_EQ (Value (list->data ()[0 ]).toDouble (), 3 );
1875+ ASSERT_EQ (Value (list->data ()[1 ]).toDouble (), 1 );
1876+ }
1877+
1878+ TEST_F (LooksBlocksTest, BackdropNumberName_SpriteBackdropName)
1879+ {
1880+ auto sprite = std::make_shared<Sprite>();
1881+
1882+ auto stage = std::make_shared<Stage>();
1883+ auto backdrop1 = std::make_shared<Costume>(" backdrop1" , " a" , " png" );
1884+ auto backdrop2 = std::make_shared<Costume>(" backdrop2" , " b" , " png" );
1885+ auto testBackdrop = std::make_shared<Costume>(" test" , " c" , " svg" );
1886+ stage->addCostume (backdrop1);
1887+ stage->addCostume (backdrop2);
1888+ stage->addCostume (testBackdrop);
1889+
1890+ m_engine->setTargets ({ stage, sprite });
1891+ ScriptBuilder builder (m_extension.get (), m_engine, sprite);
1892+
1893+ builder.addBlock (" looks_backdropnumbername" );
1894+ builder.addDropdownField (" NUMBER_NAME" , " name" );
1895+ builder.captureBlockReturnValue ();
1896+ builder.build ();
1897+
1898+ stage->setCostumeIndex (2 );
1899+ builder.run ();
1900+
1901+ stage->setCostumeIndex (0 );
1902+ builder.run ();
1903+
1904+ List *list = builder.capturedValues ();
1905+ ASSERT_EQ (list->size (), 2 );
1906+ ASSERT_EQ (Value (list->data ()[0 ]).toString (), " test" );
1907+ ASSERT_EQ (Value (list->data ()[1 ]).toString (), " backdrop1" );
1908+ }
1909+
1910+ TEST_F (LooksBlocksTest, BackdropNumberName_StageBackdropNumber)
1911+ {
1912+ auto stage = std::make_shared<Stage>();
1913+ auto backdrop1 = std::make_shared<Costume>(" backdrop1" , " a" , " png" );
1914+ auto backdrop2 = std::make_shared<Costume>(" backdrop2" , " b" , " png" );
1915+ auto testBackdrop = std::make_shared<Costume>(" test" , " c" , " svg" );
1916+ stage->addCostume (backdrop1);
1917+ stage->addCostume (backdrop2);
1918+ stage->addCostume (testBackdrop);
1919+
1920+ ScriptBuilder builder (m_extension.get (), m_engine, stage);
1921+
1922+ builder.addBlock (" looks_backdropnumbername" );
1923+ builder.addDropdownField (" NUMBER_NAME" , " number" );
1924+ builder.captureBlockReturnValue ();
1925+ builder.build ();
1926+
1927+ stage->setCostumeIndex (2 );
1928+ builder.run ();
1929+
1930+ stage->setCostumeIndex (0 );
1931+ builder.run ();
1932+
1933+ List *list = builder.capturedValues ();
1934+ ASSERT_EQ (list->size (), 2 );
1935+ ASSERT_EQ (Value (list->data ()[0 ]).toDouble (), 3 );
1936+ ASSERT_EQ (Value (list->data ()[1 ]).toDouble (), 1 );
1937+ }
1938+
1939+ TEST_F (LooksBlocksTest, BackdropNumberName_StageBackdropName)
1940+ {
1941+ auto stage = std::make_shared<Stage>();
1942+ auto backdrop1 = std::make_shared<Costume>(" backdrop1" , " a" , " png" );
1943+ auto backdrop2 = std::make_shared<Costume>(" backdrop2" , " b" , " png" );
1944+ auto testBackdrop = std::make_shared<Costume>(" test" , " c" , " svg" );
1945+ stage->addCostume (backdrop1);
1946+ stage->addCostume (backdrop2);
1947+ stage->addCostume (testBackdrop);
1948+
1949+ ScriptBuilder builder (m_extension.get (), m_engine, stage);
1950+
1951+ builder.addBlock (" looks_backdropnumbername" );
1952+ builder.addDropdownField (" NUMBER_NAME" , " name" );
1953+ builder.captureBlockReturnValue ();
1954+ builder.build ();
1955+
1956+ stage->setCostumeIndex (2 );
1957+ builder.run ();
1958+
1959+ stage->setCostumeIndex (0 );
1960+ builder.run ();
1961+
1962+ List *list = builder.capturedValues ();
1963+ ASSERT_EQ (list->size (), 2 );
1964+ ASSERT_EQ (Value (list->data ()[0 ]).toString (), " test" );
1965+ ASSERT_EQ (Value (list->data ()[1 ]).toString (), " backdrop1" );
1966+ }
0 commit comments