Ejemplo n.º 1
0
        public void KhronosLogMap_Commands()
        {
            KhronosLogMap m = new KhronosLogMap();

            Assert.IsNotNull(m.Commands);
            CollectionAssert.IsEmpty(m.Commands);

            m.Commands = new[] {
                new KhronosLogMap.Command {
                    Name   = "command",
                    Params = new[] {
                        new KhronosLogMap.CommandParam {
                            Name = "arg0", Flags = KhronosLogCommandParameterFlags.Enum
                        },
                        new KhronosLogMap.CommandParam {
                            Name = "arg1", Flags = KhronosLogCommandParameterFlags.None
                        },
                        new KhronosLogMap.CommandParam {
                            Name = "arg2",                                                     /* Flags defaults to None */
                        }
                    }
                }
            };

            Assert.IsNotNull(m.Commands);
            Assert.AreEqual(1, m.Commands.Length);

            Assert.DoesNotThrow(() => m.Commands = null);
            Assert.IsNotNull(m.Commands);
            CollectionAssert.IsEmpty(m.Commands);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generate log map information, in XML.
        /// </summary>
        /// <param name="ctx">
        /// The <see cref="RegistryContext"/> holding the OpenGL specification information.
        /// </param>
        /// <param name="path">
        /// A <see cref="String"/> that specifies the log map file path.
        /// </param>
        public void GenerateLogMap(RegistryContext ctx, string path)
        {
            KhronosLogMap logMap = new KhronosLogMap();
            List <KhronosLogMap.Command> logCommands = new List <KhronosLogMap.Command>();

            foreach (Command command in _Registry.Commands)
            {
                if (command.Parameters.Exists(delegate(CommandParameter item) { return(item.IsEnum); }) == false)
                {
                    continue;
                }

                KhronosLogMap.Command             logCommand       = new KhronosLogMap.Command();
                List <KhronosLogMap.CommandParam> logCommandParams = new List <KhronosLogMap.CommandParam>();

                foreach (CommandParameter commandParameter in command.Parameters)
                {
                    KhronosLogMap.CommandParam logParameter = new KhronosLogMap.CommandParam();
                    logParameter.Name  = commandParameter.Name;
                    logParameter.Flags = KhronosLogCommandParameterFlags.None;
                    if (commandParameter.IsEnum)
                    {
                        logParameter.Flags |= KhronosLogCommandParameterFlags.Enum;
                    }
                    logCommandParams.Add(logParameter);
                }

                logCommand.Name   = command.Prototype.Name;
                logCommand.Params = logCommandParams.ToArray();
                logCommands.Add(logCommand);
            }
            logMap.Commands = logCommands.ToArray();

            KhronosLogMap.Save(path, logMap);
        }
Ejemplo n.º 3
0
        public void KhronosLogMap_GetCommandParameterFlag()
        {
            KhronosLogMap m = new KhronosLogMap();

            Assert.Throws <ArgumentNullException>(() => m.GetCommandParameterFlag(null, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => m.GetCommandParameterFlag("command", -1));

            m.Commands = new[] {
                new KhronosLogMap.Command {
                    Name   = "command",
                    Params = new[] {
                        new KhronosLogMap.CommandParam {
                            Name = "arg0", Flags = KhronosLogCommandParameterFlags.Enum
                        },
                        new KhronosLogMap.CommandParam {
                            Name = "arg1", Flags = KhronosLogCommandParameterFlags.None
                        },
                        new KhronosLogMap.CommandParam {
                            Name = "arg2",                                                      /* Flags defaults to None */
                        }
                    }
                }
            };

            Assert.AreEqual(KhronosLogCommandParameterFlags.Enum, m.GetCommandParameterFlag("command", 0));
            Assert.AreEqual(KhronosLogCommandParameterFlags.None, m.GetCommandParameterFlag("command", 1));
            Assert.AreEqual(KhronosLogCommandParameterFlags.None, m.GetCommandParameterFlag("command", 2));
            Assert.Throws <ArgumentOutOfRangeException>(() => m.GetCommandParameterFlag("command", 3));

            Assert.AreEqual(KhronosLogCommandParameterFlags.None, m.GetCommandParameterFlag("command2", 0));
            Assert.AreEqual(KhronosLogCommandParameterFlags.None, m.GetCommandParameterFlag("command2", 1));
            // Unknown commands cannot check parameter index
            Assert.DoesNotThrow(() => m.GetCommandParameterFlag("command2", 1024));
            Assert.AreEqual(KhronosLogCommandParameterFlags.None, m.GetCommandParameterFlag("command2", 1024));
        }
Ejemplo n.º 4
0
        public void KhronosLogMap_Constructor()
        {
            KhronosLogMap m = null;

            Assert.DoesNotThrow(() => m = new KhronosLogMap());
            Assert.IsNotNull(m.Commands);
            CollectionAssert.IsEmpty(m.Commands);
        }
Ejemplo n.º 5
0
        public void KhronosLogMap_Save()
        {
            KhronosLogMap m = new KhronosLogMap {
                Commands = new[] {
                    new KhronosLogMap.Command {
                        Name   = "command",
                        Params = new[] {
                            new KhronosLogMap.CommandParam {
                                Name = "arg0", Flags = KhronosLogCommandParameterFlags.Enum
                            },
                            new KhronosLogMap.CommandParam {
                                Name = "arg1", Flags = KhronosLogCommandParameterFlags.None
                            },
                            new KhronosLogMap.CommandParam {
                                Name = "arg2",                                                         /* Flags defaults to None */
                            }
                        }
                    }
                }
            };

            Assert.DoesNotThrow(() => KhronosLogMap.Save("KhronosLogMap_Save.xml", m));
        }
Ejemplo n.º 6
0
        public void KhronosLosContext_ToString()
        {
            KhronosLogMap m = new KhronosLogMap {
                Commands = new[] {
                    new KhronosLogMap.Command {
                        Name   = "glCommand2",
                        Params = new[] {
                            new KhronosLogMap.CommandParam {
                                Name = "arg0", Flags = KhronosLogCommandParameterFlags.Enum
                            },
                            new KhronosLogMap.CommandParam {
                                Name = "arg1", Flags = KhronosLogCommandParameterFlags.None
                            },
                            new KhronosLogMap.CommandParam {
                                Name = "arg2",                                                         /* Flags defaults to None */
                            }
                        }
                    }
                }
            };
            KhronosLogContext ctx = new KhronosLogContext(typeof(TestApi), m);

            Assert.Throws <ArgumentNullException>(() => ctx.ToString(null, null, null));

            Assert.AreEqual("glCommand()", ctx.ToString("glCommand", null, null));
            Assert.AreEqual("glCommand() = -1", ctx.ToString("glCommand", -1, null));
            Assert.AreEqual("glCommand(15)", ctx.ToString("glCommand", null, new object[] { 15 }));
            Assert.AreEqual("glCommand(\"value\")", ctx.ToString("glCommand", null, new object[] { "value" }));
            Assert.AreEqual("glCommand(0x00000000)", ctx.ToString("glCommand", null, new object[] { IntPtr.Zero }));
            Assert.AreEqual("glCommand({15,16,17})", ctx.ToString("glCommand", null, new object[] { new[] { 15, 16, 17 } }));
            Assert.AreEqual("glCommand({15,16,17}, 18, 19)", ctx.ToString("glCommand", null, new object[] { new[] { 15, 16, 17 }, 18, 19 }));
            Assert.AreEqual("glCommand({a,b,c}, 18, 19)", ctx.ToString("glCommand", null, new object[] { new[] { "a", "b", "c" }, 18, 19 }));
            Assert.AreEqual("glCommand(null)", ctx.ToString("glCommand", null, new object[] { null }));

            Assert.AreEqual("glCommand2(NONE, 0, 0)", ctx.ToString("glCommand2", null, new object[] { 0, 0, 0 }));
            Assert.AreEqual("glCommand2({ONE,TWO}, 1, 2)", ctx.ToString("glCommand2", null, new object[] { new[] { 1, 2 }, 1, 2 }));
        }
Ejemplo n.º 7
0
 public void KhronosLogMap_Load()
 {
     Assert.Throws <ArgumentNullException>(() => KhronosLogMap.Load(null));
 }