-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidx_test.go
69 lines (55 loc) · 1.38 KB
/
idx_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package win32metadata
import (
"bytes"
"debug/pe"
_ "embed"
"testing"
"github.com/stretchr/testify/require"
"github.com/tdakkota/win32metadata/md"
"github.com/tdakkota/win32metadata/types"
)
var (
//go:embed md/_testdata/Windows.Win32.winmd
win32 []byte
)
func TestIssue33(t *testing.T) {
a := require.New(t)
f, err := pe.NewFile(bytes.NewReader(win32))
a.NoError(err)
defer f.Close()
c, err := types.FromPE(f)
a.NoError(err)
tt := c.Table(md.InterfaceImpl)
var row types.InterfaceImpl
for i := uint32(0); i < tt.RowCount(); i++ {
a.NoError(row.FromRow(tt.Row(i)))
class, err := row.ResolveClass(c)
a.NoError(err)
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ishellitemarray
if class.TypeNamespace != "Windows.Win32.UI.Shell" ||
class.TypeName != "IShellItemArray" {
continue
}
ns, name, err := c.ResolveTypeDefOrRefName(row.Interface)
a.NoError(err)
a.Equal("Windows.Win32.System.Com", ns)
a.Equal("IUnknown", name)
methods, err := class.ResolveMethodList(c)
a.NoError(err)
var names []string
for _, m := range methods {
names = append(names, m.Name)
}
a.Equal([]string{
"BindToHandler",
"GetPropertyStore",
"GetPropertyDescriptionList",
"GetAttributes",
"GetCount",
"GetItemAt",
"EnumItems",
}, names)
return
}
t.Fatal("Can't find Windows.Win32.UI.Shell.IShellItemArray")
}