Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate top level ReactInstanceManager changes #30

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0578c1d
Adding JS Executor
erikschlegel Dec 15, 2015
28bd102
Adding core react components
erikschlegel Dec 16, 2015
66487eb
Deleting unused stub files.
rozele Dec 16, 2015
285d7dc
Recent Changes
erikschlegel Dec 17, 2015
c036edc
On behalf of Erik Schlegel - Adding partial implementation of react c…
rozele Dec 22, 2015
12c830f
Adding ReactContext
erikschlegel Dec 17, 2015
4d04fac
Adding ReactContext
erikschlegel Dec 17, 2015
8039a45
Minor fit and finish stuff Erik's stuff.
rozele Dec 22, 2015
ab45411
On behalf of @erikschlegel - Adding top level integration functionali…
rozele Dec 23, 2015
bda9616
Addresses some fit and finish on the ReactWindows-ES branch
rozele Dec 23, 2015
c213636
Fixes JavaScriptBundleLoader, removing transfer of control to JavaScr…
rozele Dec 23, 2015
a5bf6f3
Refactoring changes to react instance manager
erikschlegel Dec 24, 2015
cd54b61
Fixes #32 - Adds UIManagerModule constants
rozele Dec 24, 2015
0014abe
Merge pull request #35 from CatalystCode/issue32
rozele Dec 26, 2015
c13131b
Adding XAML Integration
erikschlegel Dec 26, 2015
f5e8003
Merge branch 'ReactWindows-ES' of https://github.com/CatalystCode/rea…
erikschlegel Dec 26, 2015
68c5406
Comment out code to initialize UIManagerModule constants until unit t…
rozele Dec 28, 2015
9b2b4ef
Create Readme.md
erikschlegel Dec 28, 2015
7d3b51b
Update Readme.md
erikschlegel Dec 28, 2015
77a107d
Update Readme.md
erikschlegel Dec 28, 2015
d543552
Update Readme.md
erikschlegel Dec 28, 2015
dfc20e4
Fixes #62 - Adds EventDispatcher
rozele Dec 28, 2015
fff19f0
Merge pull request #63 from CatalystCode/issue62
rozele Dec 28, 2015
7b10a65
Fixing issue with unit test and variuos bugs in ReactInstanceManager
erikschlegel Dec 29, 2015
ddce726
Code to dispose ReactInstanceMgr and RootView. Fixes #65
erikschlegel Dec 29, 2015
51801bf
Fixes #64 - Adds UIImplementation
rozele Dec 29, 2015
57ab02e
Fixes #68 - Implements ReactPropertyAttribute and ReactPropertyGroupA…
rozele Dec 30, 2015
4383c16
Merge pull request #72 from CatalystCode/issue64
rozele Dec 30, 2015
fc210ec
Fixed some bugs related to the react JS bundling
erikschlegel Dec 30, 2015
57e5f34
Merge branch 'ReactWindows-ES' of https://github.com/CatalystCode/rea…
erikschlegel Dec 30, 2015
4fc003f
Fixes #73 - Adds ViewGroupManager implementation.
rozele Dec 30, 2015
bc41732
Adding .csproj changes for ViewGroupManager.
rozele Dec 30, 2015
d4e116c
Towards #70 - Adds implementation for NativeViewHierarchyManager
rozele Dec 30, 2015
bb9a76c
Merge pull request #76 from CatalystCode/issue70
rozele Dec 30, 2015
ad4edef
Adding ReactRootManager
erikschlegel Dec 30, 2015
b2251e7
Adding ReactRootManager
erikschlegel Dec 30, 2015
7355474
Ignore failing test until the XAML custom control issue is resolved. …
erikschlegel Dec 30, 2015
5cb6d5e
Towards #70 - Implements the NativeViewHierarchyOptimizer
rozele Dec 30, 2015
02def6e
Towards #70 - Adds implementation of ReactShadowNode
rozele Dec 31, 2015
38c0476
Merge pull request #77 from CatalystCode/issue70
rozele Dec 31, 2015
313d33c
ViewManager and ViewGroupManager generic and non-generic variants.
rozele Dec 31, 2015
2b5696d
Cleaning up virtuals in ViewGroupManager generic base class.
rozele Dec 31, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ private void detachViewFromInstance(
CatalystInstance catalystInstance) {
UiThreadUtil.assertOnUiThread();
catalystInstance.getJSModule(AppRegistry.class)
.unmountApplicationComponentAtRootTag(rootView.getId());
.unmountApplicationComponentAtRootTag(rootView.getId());
}

private void tearDownReactContext(ReactContext reactContext) {
Expand Down
5 changes: 5 additions & 0 deletions ReactWindows/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
<Name>ReactNative</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Facebook.CSSLayout">
<HintPath>..\References\Facebook.CSSLayout.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public async Task CatalystInstance_GetModules()
Registry = registry,
JavaScriptModulesConfig = jsConfig,
JavaScriptExecutor = executor,
BundleLoader = JavaScriptBundleLoader.CreateFileLoader("ms-appx:///Resources/test.js"),
NativeModuleCallExceptionHandler = _ => { }
};

Expand Down Expand Up @@ -63,6 +64,7 @@ public async Task CatalystInstance_Initialize_Dispose()
Registry = registry,
JavaScriptModulesConfig = jsConfig,
JavaScriptExecutor = executor,
BundleLoader = JavaScriptBundleLoader.CreateFileLoader("ms-appx:///Resources/test.js"),
NativeModuleCallExceptionHandler = _ => { },
};

Expand Down Expand Up @@ -108,6 +110,7 @@ public async Task CatalystInstance_ExceptionHandled_Disposes()
Registry = registry,
JavaScriptModulesConfig = jsConfig,
JavaScriptExecutor = executor,
BundleLoader = JavaScriptBundleLoader.CreateFileLoader("ms-appx:///Resources/test.js"),
NativeModuleCallExceptionHandler = handler,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ReactNative.Bridge;
using ReactNative.Modules.Core;
using ReactNative.UIManager;
using ReactNative.UIManager.Events;
using System;
using System.Collections.Generic;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,61 @@ public void JavaScriptModulesConfig_MethodOverrides_ThrowsNotSupported()
[TestMethod]
public void JavaScriptModulesConfig_WriteModuleDefinitions()
{
var builder = new JavaScriptModulesConfig.Builder();
builder.Add<TestJavaScriptModule>();
var config = builder.Build();
var config = new JavaScriptModulesConfig.Builder()
.Add<TestJavaScriptModule>()
.Build();

using (var stringWriter = new StringWriter())
{
using (var writer = new JsonTextWriter(stringWriter))
{
config.WriteModuleDescriptions(writer);
}

var actual = stringWriter.ToString();
var expected = JObject.FromObject(
new Map
{
{
"TestJavaScriptModule",
new Map
{
{ "moduleID", 0 },
{
"methods",
new Map
{
{
"Bar",
new Map
{
{ "methodID", 0 },
}
},
{
"Foo",
new Map
{
{ "methodID", 1 },
}
}
}
}
}
}
}
).ToString(Formatting.None);

Assert.AreEqual(expected, actual);
}
}

[TestMethod]
public void JavaScriptModulesConfig_NonGenericAdd_WriteModuleDefinitions()
{
var config = new JavaScriptModulesConfig.Builder()
.Add(typeof(TestJavaScriptModule))
.Build();

using (var stringWriter = new StringWriter())
{
Expand Down Expand Up @@ -69,6 +121,29 @@ public void JavaScriptModulesConfig_WriteModuleDefinitions()
Assert.AreEqual(expected, actual);
}
}


[TestMethod]
public void JavaScriptModulesConfig_NonGenericAdd()
{
var builder = new JavaScriptModulesConfig.Builder();

AssertEx.Throws<ArgumentException>(
() => builder.Add(typeof(JavaScriptModuleBase)),
ex => Assert.AreEqual("moduleType", ex.ParamName));

AssertEx.Throws<ArgumentException>(
() => builder.Add(typeof(IDerivedJavaScriptModule)),
ex => Assert.AreEqual("moduleType", ex.ParamName));

AssertEx.Throws<ArgumentException>(
() => builder.Add(typeof(object)),
ex => Assert.AreEqual("moduleType", ex.ParamName));

AssertEx.Throws<ArgumentException>(
() => builder.Add(typeof(NoConstructorJavaScriptModule)),
ex => Assert.AreEqual("moduleType", ex.ParamName));
}
}

public class Map : Dictionary<string, object> { }
Expand All @@ -87,6 +162,16 @@ public void Foo(int x)
}
}

public interface IDerivedJavaScriptModule : IJavaScriptModule
{

}

public class NoConstructorJavaScriptModule : JavaScriptModuleBase
{
private NoConstructorJavaScriptModule() { }
}

public class TestJavaScriptModule : JavaScriptModuleBase
{
public void Bar()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ReactNative.Bridge;
using System;

namespace ReactNative.Tests.Bridge
{
[TestClass]
public class ReactContextNativeModuleBaseTests
{
[TestMethod]
public void ReactContextNativeModuleBase_ArgumentChecks()
{
AssertEx.Throws<ArgumentNullException>(
() => new TestModule(null),
ex => Assert.AreEqual("reactContext", ex.ParamName));

var context = new ReactApplicationContext();
var module = new TestModule(context);
Assert.AreSame(context, module.Context);
}

class TestModule : ReactContextNativeModuleBase
{
public TestModule(ReactApplicationContext reactContext)
: base(reactContext)
{
}

public override string Name
{
get
{
return "Test";
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Collections.Generic;

namespace ReactNative.Tests.Constants
{
static class DictionaryHelpers
{
public static TValue Get<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
{
var result = default(TValue);
if (dictionary.TryGetValue(key, out result))
{
return result;
}

return default(TValue);
}

public static IReadOnlyDictionary<string, object> AsMap(this object value)
{
return value as IReadOnlyDictionary<string, object>;
}

public static object GetValue(this object value, string key)
{
var map = value.AsMap();
if (map == null)
{
return null;
}

return map.Get(key);
}

public static IReadOnlyDictionary<string, object> GetMap(this object value, string key)
{
return GetValue(value, key).AsMap();
}
}
}
2 changes: 2 additions & 0 deletions ReactWindows/ReactNative.Tests/Internal/JavaScriptHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public static async Task Initialize(ChakraJavaScriptExecutor executor, IMessageQ

await jsQueueThread.CallOnQueue(() =>
{
executor.Initialize();

foreach (var script in scripts)
{
executor.RunScript(script);
Expand Down
22 changes: 22 additions & 0 deletions ReactWindows/ReactNative.Tests/Internal/MockCatalystInstance.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json.Linq;
using ReactNative.Bridge;
using ReactNative.Bridge.Queue;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -32,6 +33,14 @@ public MockCatalystInstance(Action<int, JArray> callback, Action<int, int, JArra
_function = function;
}

public bool IsDisposed
{
get
{
throw new NotImplementedException();
}
}

public IEnumerable<INativeModule> NativeModules
{
get
Expand All @@ -40,6 +49,14 @@ public IEnumerable<INativeModule> NativeModules
}
}

public ICatalystQueueConfiguration QueueConfiguration
{
get
{
throw new NotImplementedException();
}
}

public T GetNativeModule<T>() where T : INativeModule
{
throw new NotImplementedException();
Expand All @@ -64,5 +81,10 @@ public void InvokeFunction(int moduleId, int methodId, JArray arguments, string
{
_function(moduleId, methodId, arguments, tracingName);
}

public void Dispose()
{
throw new NotImplementedException();
}
}
}
32 changes: 32 additions & 0 deletions ReactWindows/ReactNative.Tests/Internal/MockEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Newtonsoft.Json.Linq;
using ReactNative.UIManager.Events;
using System;

namespace ReactNative.Tests
{
class MockEvent : Event
{
private readonly string _eventName;
private readonly JObject _eventArgs;

public MockEvent(int viewTag, TimeSpan timestamp, string eventName, JObject eventArgs)
: base(viewTag, timestamp)
{
_eventName = eventName;
_eventArgs = eventArgs;
}

public override string EventName
{
get
{
return _eventName;
}
}

public override void Dispatch(RCTEventEmitter eventEmitter)
{
eventEmitter.receiveEvent(ViewTag, EventName, _eventArgs);
}
}
}
13 changes: 11 additions & 2 deletions ReactWindows/ReactNative.Tests/Internal/MockJavaScriptExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,40 @@ namespace ReactNative.Tests
class MockJavaScriptExecutor : IJavaScriptExecutor
{
private readonly Func<string, string, JArray, JToken> _onCall;
private readonly Action<string> _runScript;
private readonly Action<string, JToken> _onSetGlobalVariable;
private readonly Action _onDispose;

public MockJavaScriptExecutor(
Func<string, string, JArray, JToken> onCall)
: this(onCall, (_, __) => { }, () => { })
: this(onCall, _ => { }, (_, __) => { }, () => { })
{
}

public MockJavaScriptExecutor(
Func<string, string, JArray, JToken> onCall,
Action<string> runScript,
Action<string, JToken> onSetGlobalVariable,
Action onDispose)
{
_onCall = onCall;
_runScript = runScript;
_onSetGlobalVariable = onSetGlobalVariable;
_onDispose = onDispose;
}

public void Initialize() { }

public JToken Call(string moduleName, string methodName, JArray arguments)
{
return _onCall(moduleName, methodName, arguments);
}

public void RunScript(string script)
{
_runScript(script);
}

public void SetGlobalVariable(string propertyName, JToken value)
{
_onSetGlobalVariable(propertyName, value);
Expand All @@ -40,6 +50,5 @@ public void Dispose()
{
_onDispose();
}

}
}
Loading