remove YGMarker code
Summary: Removes code for now unused marker based approach Reviewed By: davidaurelio Differential Revision: D16048800 fbshipit-source-id: 228e0e906252782ee0bed543728b666d1f9cc854
This commit is contained in:
committed by
Facebook Github Bot
parent
7c891db9af
commit
5e40e4b682
@@ -15,7 +15,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/YGMarker.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
@@ -27,7 +26,7 @@ struct TypedEventTestData {};
|
||||
template <>
|
||||
struct TypedEventTestData<Event::LayoutPassEnd> {
|
||||
void* layoutContext;
|
||||
YGMarkerLayoutData layoutData;
|
||||
LayoutData layoutData;
|
||||
};
|
||||
|
||||
struct EventArgs {
|
||||
@@ -147,7 +146,7 @@ TEST_F(EventTest, layout_events_single_node) {
|
||||
ASSERT_EQ(events[3].node, root);
|
||||
ASSERT_EQ(events[3].type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
events[3].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 1);
|
||||
@@ -170,7 +169,7 @@ TEST_F(EventTest, layout_events_counts_multi_node_layout) {
|
||||
ASSERT_EQ(events[11].node, root);
|
||||
ASSERT_EQ(events[11].type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
events[11].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 3);
|
||||
@@ -191,7 +190,7 @@ TEST_F(EventTest, layout_events_counts_cache_hits_single_node_layout) {
|
||||
ASSERT_EQ(events[6].node, root);
|
||||
ASSERT_EQ(events[6].type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
events[6].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 0);
|
||||
@@ -215,7 +214,7 @@ TEST_F(EventTest, layout_events_counts_cache_hits_multi_node_layout) {
|
||||
ASSERT_EQ(lastEvent().node, root);
|
||||
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 3);
|
||||
@@ -240,7 +239,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) {
|
||||
ASSERT_EQ(lastEvent().node, root);
|
||||
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 3);
|
||||
|
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <yoga/Yoga.h>
|
||||
#include <yoga/YGMarker.h>
|
||||
#include <yoga/instrumentation.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
bool operator==(const YGMarkerLayoutData&, const YGMarkerLayoutData&);
|
||||
void PrintTo(const YGMarkerLayoutData, std::ostream*);
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
namespace test {
|
||||
|
||||
template <typename T>
|
||||
using uniquePtr = std::unique_ptr<T, std::function<void(T*)>>;
|
||||
|
||||
struct MarkerTest : public ::testing::Test {
|
||||
struct Data {
|
||||
YGMarker marker;
|
||||
YGNodeRef node;
|
||||
YGMarkerData markerData;
|
||||
};
|
||||
|
||||
struct EndData {
|
||||
Data data;
|
||||
void* cookie;
|
||||
union {
|
||||
YGMarkerLayoutData layout;
|
||||
} markerData;
|
||||
};
|
||||
|
||||
struct MarkerCookie {
|
||||
Data start;
|
||||
EndData end;
|
||||
};
|
||||
|
||||
// std::deque will keep pointers stable on reallocation, whereas std::vector
|
||||
// does not
|
||||
static std::deque<MarkerCookie> markerCookies;
|
||||
|
||||
static void* startMarker(YGMarker, YGNodeRef, YGMarkerData);
|
||||
static void endMarker(YGMarker, YGNodeRef, YGMarkerData, void*);
|
||||
uniquePtr<YGNode> makeNode();
|
||||
uniquePtr<YGNode> addChild(uniquePtr<YGNode>& owner);
|
||||
static void calculateLayout(
|
||||
uniquePtr<YGNode>& node,
|
||||
float width = YGUndefined,
|
||||
float height = YGUndefined);
|
||||
static MarkerCookie& findMarker(YGMarker);
|
||||
static MarkerCookie& findLastMarker(YGMarker);
|
||||
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
uniquePtr<YGConfig> config;
|
||||
};
|
||||
|
||||
void* MarkerTest::startMarker(
|
||||
YGMarker marker,
|
||||
YGNodeRef node,
|
||||
YGMarkerData data) {
|
||||
markerCookies.emplace_back();
|
||||
MarkerCookie* cookie = &markerCookies.back();
|
||||
cookie->start = {marker, node, data};
|
||||
return cookie;
|
||||
}
|
||||
|
||||
void MarkerTest::endMarker(
|
||||
YGMarker marker,
|
||||
YGNodeRef node,
|
||||
YGMarkerData data,
|
||||
void* id) {
|
||||
auto cookie = static_cast<MarkerCookie*>(id);
|
||||
cookie->end = {{marker, node, data}, id, {}};
|
||||
}
|
||||
|
||||
uniquePtr<YGNode> MarkerTest::makeNode() {
|
||||
auto n = uniquePtr<YGNode>{YGNodeNewWithConfig(config.get()), &YGNodeFree};
|
||||
return n;
|
||||
}
|
||||
|
||||
uniquePtr<YGNode> MarkerTest::addChild(uniquePtr<YGNode>& owner) {
|
||||
auto n = makeNode();
|
||||
YGNodeInsertChild(owner.get(), n.get(), YGNodeGetChildCount(owner.get()));
|
||||
return n;
|
||||
}
|
||||
|
||||
void MarkerTest::calculateLayout(
|
||||
uniquePtr<YGNode>& node,
|
||||
float width,
|
||||
float height) {
|
||||
YGNodeCalculateLayout(node.get(), width, height, YGDirectionLTR);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
const char* markerTypeName(YGMarker type) {
|
||||
return "";
|
||||
}
|
||||
|
||||
template <typename It>
|
||||
MarkerTest::MarkerCookie& find(It begin, It end, YGMarker type) {
|
||||
auto result = std::find_if(begin, end, [type](MarkerTest::MarkerCookie& c) {
|
||||
return c.start.marker == type;
|
||||
});
|
||||
if (result == end) {
|
||||
throw std::runtime_error{std::string{"No marker recorded for type: "} +
|
||||
markerTypeName(type)};
|
||||
}
|
||||
return *result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MarkerTest::MarkerCookie& MarkerTest::findMarker(YGMarker markerType) {
|
||||
return find(markerCookies.begin(), markerCookies.end(), markerType);
|
||||
}
|
||||
|
||||
MarkerTest::MarkerCookie& MarkerTest::findLastMarker(YGMarker markerType) {
|
||||
return find(markerCookies.rbegin(), markerCookies.rend(), markerType);
|
||||
}
|
||||
|
||||
void MarkerTest::SetUp() {
|
||||
config = uniquePtr<YGConfig>{YGConfigNew(), &YGConfigFree};
|
||||
YGConfigSetMarkerCallbacks(config.get(), {startMarker, endMarker});
|
||||
}
|
||||
|
||||
void MarkerTest::TearDown() {
|
||||
markerCookies.resize(0);
|
||||
}
|
||||
|
||||
decltype(MarkerTest::markerCookies) MarkerTest::markerCookies = {};
|
||||
|
||||
} // namespace test
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
||||
return lhs.layouts == rhs.layouts && lhs.measures == rhs.measures &&
|
||||
lhs.maxMeasureCache == rhs.maxMeasureCache &&
|
||||
lhs.cachedLayouts == rhs.cachedLayouts &&
|
||||
lhs.cachedMeasures == rhs.cachedMeasures;
|
||||
}
|
||||
|
||||
void PrintTo(const YGMarkerLayoutData data, std::ostream* os) {
|
||||
*os << "YGMarkerLayoutData{ layouts = " << data.layouts
|
||||
<< ", measures = " << data.measures
|
||||
<< ", maxMeasureCache = " << data.maxMeasureCache
|
||||
<< ", cachedLayouts = " << data.cachedLayouts
|
||||
<< ", cachedMeasures = " << data.cachedMeasures << " }";
|
||||
}
|
Reference in New Issue
Block a user